To help you learn and use R, there is a section highlighting the most important R code used near the end of each chapter. The bold text will never change but the lighter and/or ALL CAPS text (red in the online or digital version) will need to be customized to your particular application. The sub-bullet for each function will discuss the use of the function and pertinent options or packages required. You can use this as a guide to finding the function names and some hints about options that will help you to get the code to work. You can also revisit the worked examples using each of the functions.
FILENAME <-
read_csv(“path to csv file/FILENAME.csv”)
Can be generated using “Import Dataset” button or by modifying this text.
Requires the readr
package to be loaded (require(readr)
) when using
the code directly.
Imports a text file saved in the CSV format.
DATASETNAME$VARIABLENAME
head(DATASETNAME)
tail(DATASETNAME)
mean(DATASETNAME$VARIABLENAME)
sd(DATASETNAME$VARIABLENAME)
favstats(DATASETNAME$VARIABLENAME)
Requires the mosaic
package to be loaded (require(mosaic
) after
installing the package).
Provides a suite of numerical summaries of the observations in a variable.
hist(DATASETNAME$VARIABLENAME)
boxplot(DATASETNAME$VARIABLENAME)