When you have data in a CSV, you can load it into a data frame in R using readr‘s read_csv() function:

df <- read_csv('my_csv_file.csv')
  • In the example above, the read_csv() function is called
  • The CSV file my_csv_file.csv is passed in as an argument
  • A data frame containing the data from my_csv_file.csv is returned

You can also save data from a data frame to a CSV using readr‘s write_csv() function:


In the example above, write_csv() takes two arguments:

  • df, which represents a data frame object
  • new_csv_file.csv, the name of the CSV file that will hold the data from the data frame

By default, this method will save the CSV file to your current directory.



artists.csv contains data from the top 7 most popular music groups of 2018. Within the empty code block, load the CSV into a data frame artists. On the line below, type artists and run the code to view the rendered data frame.

Use the arrows to view the different columns of the data frame!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?