Introduction to R (Part 2)
After completing this lab, you should be able to:
- Reference files using absolute and relative paths.
- Create an R data frame from a data file stored on your computer.
- Convert numeric or character vectors to factors.
- Index vectors and data frames.
Prepare for the Lab
- Make sure you grasp the concepts from lab 1.
- Read Workflow: projects from R for Data Science.
- Read the following sections from Learning Statistics with R:
Researchers at the Vancouver and Okanagan campuses of The University of British Columbia have conducted a survey of child sleep. The results of this survey are found in the file child-sleep-data.csv. The table below provides names and descriptions for each variable in the data set.
|id||A randomly generated participant ID, unique to each participant.|
|age</age>||The age of the child in the study.</tr>|
|campus||The campus from which the participant was recruited ("Point Grey" or "Okanagan").|
|sleep_location||Where does the child sleep? 1 = co-sleeps with parent(s); 2 = sleeps in own room; 3 = shares a room but does not cosleep.|
|sleep||The parent's estimate of the average hours of sleep the child receives in a 24-hour period.|