Writing to a file

  • readr also has functions for writing data back to disk: write_csv() and write_tsv().

  • Most important arguments are:

    • x (the data frame to save), and
    • file (the location to save it).
    • Also you may specify missing values with na or other, and if you want to append to an existing file.

IMPORTANT Note that the variable type information that you just set up is lost when you save to CSV because you’re starting over with reading from a plain text file again.

students
write_csv(students, "students-2.csv")
read_csv("students-2.csv")