Reputation: 1769
I'm using a write.csv statement to direct output to a file. I have several variables in the program: 'n', 'k' and 'temp'. For example: n=100, k=0.1 and temp=2000.
I would like for the output csv files to be labeled 'file name t 2000 N 100 k 01.csv'. But with the following command:
write.csv(res, file = paste0("file name t", temp,".csv"),row.names=FALSE)
I can write only 'file name t 2000.csv'. How could I write the correct label? Thanks!
Upvotes: 0
Views: 45
Reputation: 23214
#'file name t 2000 N 100 k 01.csv'.
a <- "file name t "
b <- 2000
c <- " N 100"
d <- " k 01"
write.csv(res, file = paste0(a, b, c, d, ".csv"),row.names=FALSE)
Upvotes: 1
Reputation: 2263
You can string together as many things as you want in paste0
:
paste0("file name t", temp, "N", n, "k", k, ".csv")
Though you may need to adjust the spacing to your liking.
Upvotes: 1