Load an R object after an assigning its name

Viewed 15

I am trying to find a way to save an object after an assign. I based my example on this topic that helps: How to save R data object that has been created using assign()?

The object is correctly saved when I check in the folder but impossible to open it with R. When I try to open it, I have the regular question whether I want to load it, then nothing appears in my environment (with and without number at the beginning of its name ...).

Do you have an idea ?

Here is my example:

res <- 12345
sku = 'sku_a'
index = 1
# index = 'hello'
# create variable based on string combination
# assign variable value with res

assign(paste0(index,'_arima_',sku), res) 

paste0(index,'_arima_',sku) %>% save(file = paste0(index,'_arima_',sku,'.RData'))
paste0(index,'_arima_',sku) %>% save(file = paste0('_arima_',sku,'.RData'))
paste0(index,'_arima_',sku) %>% save(file = paste0(index,'_arima_',sku,'.RData'))

Thanks a lot in advance,

Charlotte

0 Answers
Related