Save Files in R: Complete Guide
In R language, the function write.table() can be used to save data to a file. This function can save data frames, matrices, or vectors as text files, and allows for specifying parameters such as file name, path, and delimiter. For example:
data <- data.frame(x = c(1, 2, 3), y = c(4, 5, 6))
write.table(data, "data.txt", sep = "\t", row.names = FALSE)
The code above saves the data frame ‘data’ as a file named “data.txt”, using tabs as separators and not saving the row names.