Simple Question
On Sep 27, 2012, at 11:13 PM, Bhupendrasinh Thakre wrote:
Hi Everyone, I am trying a very simple task to append the Timestamp with a variable name so something like a_2012_09_27_00_12_30 <- rnorm(1,2,1).
If you want to assign a value to a character-name you need to use ... `assign`. You cannot just stick a numeric value which is what you get with sys.Time() on the LHS of a "<-" and expect R to intuit what you intend. ?assign assign( "a_2012_09_27_00_12_30" , rnorm(1,2,1) ) assign( as.character(unclass(Sys.time())) , rnorm(1,2,1) ) (I would have thought you wanted to format that sys.Time result:)
format(Sys.time(), "%Y_%m_%d_%H_%M_%S")
[1] "2012_09_27_23_32_40"
assign(format(Sys.time(), "%Y_%m_%d_%H_%M_%S"), rnorm(1,2,1) )
grep("^2012", ls(), value=TRUE)
[1] "2012_09_27_23_33_45"
Tried some commands but it doesn't work out well. Hope someone has some answer on it. Session Info R version 2.15.1 (2012-06-22) Platform: i386-apple-darwin9.8.0/i386 (32-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] chron_2.3-42 twitteR_0.99.19 rjson_0.2.9 RCurl_1.91-1 bitops_1.0-4.1 tm_0.5-7.1 RMySQL_0.9-3 DBI_0.2-5 loaded via a namespace (and not attached): [1] slam_0.1-24 tools_2.15.1 Statement I tried : b <- unclass(Sys.time()) b = 1348812597 c_b <- rnorm(1,2,1) Works perfect but doesn't show me c_1348812597. Best Regards, Bhupendrasinh Thakre [[alternative HTML version deleted]]
BT; Please learn to post in plain text. It's really very simple with gmail.
David Winsemius, MD Alameda, CA, USA