I wanted to avoid advanced topics in this post and focus on some “blocking and tackling” with R in an effort to get novices started. This is some of the basic code I found useful when I began using R just over 6 weeks ago.
Reading in data from a .csv file is a breeze with this command.
> data = read.csv(file.choose())
No need to have your own data set as R comes with data packages already.
> data() #list the datasets available in R
> # load the dataset 'cars' and display the variables
1 4 2
2 4 10
3 7 4
4 7 22
5 8 16
6 9 10
#the command head() gives shows we have two variables, car speed and stopping distance along with the first 6 rows of data
#using attach() splits the data into separate columns and avoids having to use what I feel is the pesky $
# descriptive statistics of our two variables
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00
> # univariate plots for speed