본문 바로가기
R

(R)The way to save data frame in R as excel and csv files / read excel and csv files in R

by jangpiano 2020. 8. 24.
반응형

<Save data frame in R as an excel file - write_xlsx(the name of data frame, "file name.xlsx")>


> library(writexl)


> data_frame_2<-data.frame(Year=c(2008,2008,2008,2008,2010,2010,2010,2010,2012,2012,2012,2012,2014,2014,2014,2014,2016,2016,2016,2016,2018,2018,2018,2018,2020,2020,2020,2020),Age=c(18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21),freshmen=c(13,37,46,15,18,39,40,12,25,47,56,17,23,59,73,24,28,78,92,30,33,92,100,32,42,130,140,42))


>View(data_frame_2)



> write_xlsx(data_frame_2,path="freshmen.xlsx")



<Save data frame in R as a csv file 

                                      - write.csv(the name of data frame, file="file name.xlsx")>

> library(writexl)


> data_frame_2<-data.frame(Year=c(2008,2008,2008,2008,2010,2010,2010,2010,2012,2012,2012,2012,2014,2014,2014,2014,2016,2016,2016,2016,2018,2018,2018,2018,2020,2020,2020,2020),Age=c(18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21,18,19,20,21),freshmen=c(13,37,46,15,18,39,40,12,25,47,56,17,23,59,73,24,28,78,92,30,33,92,100,32,42,130,140,42))


> write.csv(data_frame_2,file="freshmen.csv")



<Read an excel file in R >   - read_xlsx("")


> library(readxl)


> freshmen_data_frame<-read_excel("C:/Users/END USER/Documents/freshmen.xlsx")

> View(freshmen_data_frame)



<Read a csv file in R> - read.csv("")



> freshmen_data_frame_2<-read.csv("C:/Users/END USER/Documents/freshmen.csv")


> View(freshmen_data_frame_2)



반응형