[R] save() unable to find object

Christofer Bogaso bog@@o@chr|@to|er @end|ng |rom gm@||@com
Thu Oct 31 10:09:48 CET 2019


I wanted to save a few R objects in RData file for some future use.
The names of such R objects are actually dynamic so I used below code
to save them -

Date = Sys.Date()
assign(paste('AAA', format(Date, "%d"), sep = ""), 5)
save('Date', paste('AAA', format(Date, "%d"), sep = ""), file = 'Save.RData')

With this, I am getting below error -

Error in save("Date", paste("AAA", format(Date, "%d"), sep = ""), file
= "Save.RData") :
  object ‘paste("AAA", format(Date, "%d"), sep = "")’ not found

But I have the object in the workplace -

> AAA31
[1] 5

I will really appreciate if someone can point towards the right direction.


More information about the R-help mailing list