1.2 Import data
This section uses the raw depression
data set from the Afifi et.al. textbook. This is a tab-delimited data set, so we opt to use read.table
here. We include arguments sep="\t"
to indicate columns are separated with tabs and header=TRUE
to indicate the first row of the data is the variable names.
library(ggplot2)
depress_raw <- read.table("https://norcalbiostat.netlify.com/data/Depress.txt",
sep="\t", header=TRUE)
Learn more See R for Data Science 2nd edit for more instruction on importing different types of data and ways you can streamline your data import.
https://r4ds.hadley.nz/data-import
The absolute first thing you should do is to look at your raw data table. Are the column headers variable names? Did all the rows get read in? Are there any extra columns or rows included?