Professional Documents
Culture Documents
Objective: To perform data import/export (.CSV, .XLS, .TXT) operations using data frames in
R.
Theory:
Import data: In R following command is used to import data:
• Read.csv(): This command used to read the csv(comma separated value) file.
Syntax: dataframe<-read.csv(“filename”)
•Read_excel(): This command reads the excel file and store into the R. Before executing this command a
package readxl must be installed using command install.packages(“readxl”) and activated in the R console
using command library.
Syntax: dataframe<-read_excel (“path of the file with filename”) Export data: In R programming following
commands used to export data:
•Write.table(): Exports a dataframe or matrix to a text file.
write.table(x, #Data frame to be exported file, #Full path append = FALSE, #whether to append to an existing
file sep = “ ”, #separator symbol dec = “.”, #decimal separator symbol row.names = TRUE, #whether to include
row names or not col.names = TRUE) #whether to include column names or not
•Write.csv(): Exports a dataframe to a csv(comma separated value) file. This command uses comma as a
separator and dot as decimal separator.
• Write.xlsx(): this command used to export data frame and tables from R to excel. This command uses
comma as separator and dot as decimal separator
##Ayush
Anupamverma 2100320130057
Vats – 2100320130038