[R] Writing text files out of a dataset

Luca Meyer lucam1968 at gmail.com
Fri Dec 29 15:31:44 CET 2017


Hello,

I am trying to run the following syntax for all cases within the dataframe
"data"

d1 <- data[1,c("material")]
fileConn<-file("TESTI/d1.txt")
writeLines(d1, fileConn)
close(fileConn)

I am trying to use the for function:

 for (i in 1:nrow(data)){
  d[i] <- data[i,c("material")]
  fileConn<-file("TESTI/d[i].txt")
  writeLines(d[i], fileConn)
  close(fileConn)
}

but I get the error:

Object "d" not found

Any suggestion on how I can solve the above?

Thanks,

Luca

	[[alternative HTML version deleted]]



More information about the R-help mailing list