Dear R helpers,

I am using Beta distribution to generate the random no.s (recovery rates in my example). However, each time I need to save these random no.s in a csv format. To distinguish different csv files, one way I thought was use of Sys.time in the file name. My code is as follows -

# My code

rr = rbeta(25, 6.14, 8.12)

lgd = 1 - mean(rr)

write.csv(data.frame(recovery_rates = rr), file = paste("recovery_rates_at_", Sys.time(), ".csv", sep = ""), row.names = FALSE)


However, I get following error -

Error in file(file, ifelse(append, "a", "w")) :   cannot open the connection
In addition: Warning message: In file(file, ifelse(append, "a", "w")) :
cannot open file 'recovery_rates_at_2012-07-04 1:14:05.csv': Invalid argument


If instead of Sys.time, I use some other variable e.g. lgd as 

write.csv(data.frame(recovery_rates = rr), paste('rates_',lgd,'.csv', sep = ""), row.names = FALSE)

I am able to store these simulated recovery rates in different files. But I need to use Sys.time in my csv file name. (or is there any other way of writing these csv files so that files don't get over-written).

Kindly guide.

Regards and thanking in advance

Vincy


	[[alternative HTML version deleted]]

