You have an error with the filename in the loop. Try replacing the relevant line wtih fileConn<-file(sprintf("TESTI/%d.txt",i))
HTH, Eric On Fri, Dec 29, 2017 at 4:31 PM, Luca Meyer <lucam1...@gmail.com> wrote: > 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]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.