# # Unit 8 - Data frames # # Writing a data frame into a .csv file # # Let us write this data frame into a .csv file myDF <- data.frame(ID = c(1, 2, 3), GENDER = c("M", "F", "F"), AGE = c(27, 43, 23)) print(myDF) # first wetting the working directory setwd("c:/R") # Unsurprisingly, not read.csv but ...: write.csv(myDF, file = "students.csv") myDF2 <- read.csv("students.csv") print(myDF2) # In the new file, the row labels appear. # To avoid adding them: write.csv(myDF, file = "students.csv", row.names = FALSE) myDF2 <- read.csv("students.csv") print(myDF2)