0

I am trying to write all the dataframes from a list to a csv conserving the name of the list and I am not sure what am i doing wrong. This is what I am trying as seen here :

v1<-c(0:9)
v2<-c(10:19)
v3<-c(20:29)
v4<-c(30:39)
v5<-c(40:49)
v6<-c(50:59)

lista<- cbind(v1, v2, v3)
listb<- cbind(v4, v5, v6)
list<- list(lista, list)

for (i in seq_along(list)) {
filename = paste(names(list)[i], ".csv")
write.csv(data[[i]], filename)
}

However I get this error Error in data[[i]] : object of type 'closure' is not subsettable. I know this has been asked before buy I have tried everything I could find. Many thanks!

Adela Iliescu
  • 303
  • 1
  • 3
  • 9
  • `data` is a function. You cannot subset a function with `[[`. This is what the error message means. – www Aug 04 '18 at 19:08
  • `list` is also a function. It is a bad practice to save an object with a pre-defined function name in R. – www Aug 04 '18 at 19:09
  • It seems like you just made a typo by copying others' code without making the necessary change. Thus, I decided to close it as a duplicate. – www Aug 04 '18 at 19:12

0 Answers0