Reading and Writing Data in R - Statistics-and-Machine-Learning-with-R/Statistical-Methods-and-Machine-Learning-in-R GitHub Wiki

INPUT

Click for RScript

  • The input format is quite easy. We just have to know the path of the file.

    df <- read.csv("C:/Desktop/airquality.csv")

  • “header = True” in read.csv is a logical value, indicating whether the file contains the names of the variables in the first line.

    df <- read.csv("myRandomFile.csv", header=TRUE)

OUTPUT

write.csv(Your DataFrame,"Path where you'd like to export the Data Frame \File Name.csv", row.names = FALSE)

Formally : write.csv(df,"C:\Users\Ron\Desktop\MyData.csv", row.names = FALSE)

  • row.names is used to name the first column of the dataset. It defines the name of rows.