Reputation: 10626
I am trying to write files and getting error:
this is what I am doing:
sites<-c("New York", "Boston", "San Francisco")
p<-1:10
for(i in 1:length(sites)) {
print(sites[i])
writeLines(p, paste0(gsub(" ", "_", sites[i]),".txt")
}
I get this error:
Error in writeLines(p, gsub(" ", "_", sites[i])) :
invalid 'text' argument
Upvotes: 2
Views: 6358
Reputation: 263301
sites<-c("New York", "Boston", "San Francisco")
p<-1:10
for(i in 1:length(sites)) {
print(sites[i])
writeLines(as.character(p), paste0(gsub(" ", "_", sites[i]),".txt"))
}
#----
[1] "New York"
[1] "Boston"
[1] "San Francisco"
Upvotes: 4