2 Working with Data
Statistics is based on the study of data. Without data, all we can do is make guesses. In this chapter, we will learn how to work with data in R. Specifically, how to load data into R so we can work with it, and how to explore our data by calculating summaries and plotting simple figures.
Learning Objectives
- Learn to load data into R.
- Learn to explore a dataset using numerical summaries.
- Learn to explore a dataset using simple plots.
Useful Functions
- Use
read_csv()
or theImport Dataset
button to load data into R. Use
getwd()
andsetwd()
to get and set R’s working directory.- Use
head()
andtail()
to examine the beginning and end of a dataset. - Use the
$
operator to access a particular column of a dataset. - Use
sort()
to sort data. Use
length()
,mean()
,median()
,range()
,var()
,sd()
, andtable()
to calculate numerical summaries.- Use
barplot()
to make a bar plot. - Use
hist()
to make a histogram. Use
boxplot()
to make a box plot.