简体   繁体   中英

How do I export data frame to .csv file created by read_bulk function in R?

I would like help on how to export the data frame created by merging .csv files using read bulk package in R. I have 9 .csv files with data that I merged using read_bulk in R. I tried to create an empty data frame first and then populate it with the merged data. My plan was then to export the data frame to a .csv file. This was unsuccessful. I got stuck on populating the empty data frame. Is there a better approach or edit I can make to the code I am using? Here is the code:

>data1=data.frame(Row=numeric(),Title=character(),Color=character(),Value=numeric(),stringsAsFactors=FALSE)

>read_bulk(directory=directory, data=data1)

Data is read from the .csv files and displays correctly on my R Console

>data1

[1] Row Title Color Value
<0 rows> (or 0-length row.names)

ensure your directory is set to where your CSV files are. This seemed to work for me - the combined dataframe is stored as data1

data1<-read_bulk(directory = getwd(),subdirectories = F,extension = ".csv",data = NULL)

the you can write your merged data to a combinded csv file

write.csv(data1,"bulk.csv",row.names = F,na="")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM