Previous: Special Cases When Loading Up: Loading Data Next: Saving Data

Verifying You Loaded The Data Correctly

Whichever method you use, try the names(), dim(), and summary() commands to verify that the data was properly loaded. For example,

> data <- read.csv("mydata.csv", header = TRUE)             # Read the data.
> dim(data)                    # Displays the dimensions of the data frame
[1] 16000  8                   #  in rows then columns.   
> data[1:10,]                  # Display rows 1-10 and all columns.
> names(data)                  # Check the variable names.
[1] "V1" "V2" "V3"             # These values indicate that the variables  
                               #  weren't named, and took default values.
> names(data) <- c("income", "educate", "year")     # Assign variable names. 
> summary(data)                # Returning a summary for each variable.
In this case, the summary() command will return the maximum, minimum, mean, median, first and third quartiles, as well as the number of missing values for each variable.



Gary King 2011-11-29