The data for the textbook is found here. Use the links to the .csv
data to read in the comma separated values data set. You can also view this dataset in any spreadsheet software like Excel. Here is how the first dataset, ACS.csv
, can be read into R:
> acs <- read.csv("http://www.lock5stat.com/datasets1e/ACS.csv")
> head(acs)
Sex Age Married Income HoursWk Race USCitizen HealthInsurance Language
1 0 31 0 60.00 40 white 1 1 1
2 1 31 0 0.36 12 black 1 1 0
3 1 75 0 0.00 NA white 1 1 0
4 0 80 0 0.00 NA white 1 1 0
5 1 64 1 0.00 NA white 1 1 0
6 1 14 0 NA NA white 1 1 0
To get the url address used above, simply right click on the ACS.csv
link and copy the link address. All other data sets will follow a similar url path as the one above, just using a different data set name.
If you have R downloaded on your computer, you can download all .csv
data files from this website. If you do this, you can read in any .csv
via its directory location on your computer. For example, you might store ACS.csv
in the location C:\Documents\Math215\data
on your windows machine. You can then read the data into R with the following command:
> acs <- read.csv("C:/Documents/Math215/data/ACS.csv")
Notice that windows uses backslashes \
to denote a file path but R will want a forward slash /
in its file path.
This data is also available at the collab location (on Windows) I:\Departments\MATH\MATH-Shared\Data_RLabManual
or on the online Rstudio server at /Statistics/Data_RLabManual
. But the easiest way to obtain data is to use the links that I’ve provided for most of the data that we may use in class.
The first data set used in the lab manual is states09.csv
. To read this data set into R from its url, use a right-click and copy the link address given for this file:
Then read in the data using this file address location:
> states09 <- read.csv("http://people.carleton.edu/~kstclair/data/states09.csv")
> names(states09)
[1] "State" "Region" "Population"
[4] "Births" "Deaths" "InfantMortality"
[7] "BirthsTeens" "HSGrad" "ColGrad"
[10] "Marriages" "DeathsHeart" "DeathsMV"
[13] "DeathsFirearms" "Murder" "DeathPenalty"
[16] "TheftsMV" "Robberies" "Income"
[19] "Poverty" "Homeownership" "EnergyExp"
[22] "HazardousWaste" "Restaurants"
All other lab manual dataset that are shown below follow the same basic url address as the one shown for states09
.
"/Statistics/Data_RLabManual/Pew.csv"
)(Webpage created using Rstudio!)