1. Learn
  2. /
  3. Courses
  4. /
  5. Inferential Statistics

Exercise

Getting your data into R

One important thing before you actually do analyses on your data, is that you will need to get your data into R. R contains many functions to read in data from different formats. To name only a few:

  • read.table: Reads in tabular data such as txt files
  • read.csv: Read in data from a comma-separated file format
  • readWorksheetFromFile : Reads in an excel worksheet
  • read.spss: Reads in data from .sav SPSS format.

For the current exercise, we have put the R mtcars dataset into a csv file format and put this on github. The data can be found on the following link: http://s3.amazonaws.com/assets.datacamp.com/course/uva/mtcars.csv

Instructions

100 XP
  • Load in the mtcars dataset using the read.csv function. Your code should look something like: read.csv("dataset_url"). Store the result into a variable called cars
  • Print the first 6 rows of the dataset using the head function