Ok. Now lets start with Homework 1.
First thing you need to know where your data is. In my system, I have all the Geostatistics data in my repositories folder which I can find in my home directory (/home/sevra
). The direction of your datafile is called the path. In my case it is /Users/sevra/Repos/Geostatistics/Data/10.5061.dryad.r2170/Yasuhara_Tab2-USNM.csv
. In your case, the path to the file will look different.
Now you can load the data into R using the read.csv
command we just used before. In R, type:
>homework_1_data<-read.csv("/Users/sevra/Repos/Geostatistics/Data/10.5061\/dryad.r2170/Yasuhara_Tab2-USNM.csv", head=T)
Question: what is the option head=T
doing?1.
Ok. Now you have an object in R storing the data you need to complete homework 1.
Say you want to take a look at the data you just uploaded to R, type >head(homework_1_data)
to ask R to display the first lines (i.e. the head) of your data matrix2. Say you don’t know anymore which objects you have in your Workspace3, type >ls()
to tell R to list them. Or say you want to remove an object you don’t need anymore, type >rm(name_of_object_to_delete_here)
to tell R you want to delete something4.
Good. Now, what happens if only want to know the names of the variables (columns) in my data matrix? You type >names(homework_1_data)
and voila, you get them.