Skip to content

Reading and Writing Data in R

Rahul Mondal edited this page Feb 7, 2021 · 2 revisions

INPUT

  • 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.
Clone this wiki locally