0

I loaded multiple raw datasets by using this code:

dfnames<-list.files(here::here("dataset"))
dflist<-list()
for(i in dfnames){
  dflist[[i]]<-rio::import(here::here("dataset", i))
}

which in dflist, it contains 5 datasets from the local folder "dataset", dfnames contains 5 original dataset's names.

Now I want to export them as a 5 separated .txt files by using rio::export. The datasets will be stored at the same R project environment and folder called "rawdataset".

I am stuck here: I do not know how to define the file type(.txt) in context of rio::export .

for (j in dfnames){
  rio::export(here::here("rawdataset", j))
}

Can someone help to figure out how to write that code? thx a lot~~!

Update:

Solution is:

for (j in dfnames){
  rio::export(dflist[[i]], here::here("test", str_c(j,".txt" )))
}
zx8754
  • 52,746
  • 12
  • 114
  • 209
Rstudyer
  • 309
  • 1
  • 8

0 Answers0