File Input/Output
File Input:
#If the dataset is already loaded into the R directory
read.csv("hospital_data.csv")
read_table("hospital_data.txt")
#To add a new dataset from machine downloads to directory (Mac)
read.csv("/users/username/Downloads/hospital_data.csv")
read_table("/users/username/Downloads/hospital_data.txt")
#To add a new dataset from machine desktop to directory (Windows)
read.csv("C:\\Users\\username\\Desktop\\hospital_data.csv")
read_table("C:\\Users\\username\\Desktop\\hospital_data.txt")
#Note that forward slashes are used on Mac and backwards slashes are used by WindowsFile Output:
#To output a file as a .txt file:
sink("hospital_data.txt")
#To output a file as a .csv file:
sink("hospital_data.csv")Resources:
Last updated
