The following two commands were run before the code run below because I saved all of my files in the same directory.

> library(NCStats)
> setwd("T:/Stats")
  • The object name to the left of each assignment operator (i.e., <-) can largely be whatever you want. In the examples below, I tried to uses names that made sense for the data being imported.

Loading Data from Webpage I


  1. There are four variables in BrainHead.csv.
  2. The variables in Brainhead.csv are: head.size, brain.weight, gender,
  3. There are 237 individuals in BrainHead.csv.
> bhobj <- read.csv("BrainHead.csv")
> str(bhobj)

Loading Your Own Data I

  • When entering your own data into R, make sure that variables are organized by columns (so that individuals are organized by row) and that each column has a useful name. Also make sure that your variable names and your data do not have any spaces in them as this can cause some issues with how the data are loaded into R. So, if your variable is the professor’s name don’t label that column as Professors Name; rather call it Prof, Professor, ProfName, Prof.Name, or something similar. Similarly, for the data don’t write Derek Ogle; rather use DerekOgle, Derek.Ogle, Derek_Ogle, Ogle, ProfessorDoctorOgleSir, or something similar.
  • Don’t use headtail() for data.frames that are very small. Just type the name of hte data.frame to show all of the individuals in that data.frame.
  • Answers will vary by student.

Loading Data from Webpage II


  1. There are 11 variables in PopularKids.csv.
  2. The variables in PopularKids.csv are: gender, grade, age, race, type, school, goals, grades, sports, looks, money.
  3. There are 478 individuals in PopularKids.csv.
> pkobj <- read.csv("PopularKids.csv")
> str(pkobj)


  1. There are eight variables in Yahara.csv.
  2. The variables in Yahara.csv are: year, mon, day, boats.up, boats.down,, lockings, remarks.
  3. There are 4970 individuals in Yahara.csv.
> yobj <- read.csv("Yahara.csv")
> str(yobj)

Loading Your Own Data II

  • Answers will vary by student.