RStudio background jobs: save.image() doesn't save assigned variables?

rstudio
ide
jobs

#1

When I run a background job which includes saving down the results, the resulting .RData file doesn't include most assign values.

Run this as a background job:

x <- 1
y <- 3

save.image(file = "~/Desktop/example.RData")

In console:

rm(list=ls())
load(file = "~/Desktop/example.RData")
ls()


#2

Are they saved if you explicitly list them using save? What if you ls() them inside save? I'm wondering if this is somehow an environment issue, since the bit of save.image() that does the work is:

save(list = names(.GlobalEnv), file = outfile, version = version, 
        ascii = ascii, compress = compress, envir = .GlobalEnv, 
        precheck = FALSE)

#3

Thank you @jcblum! This worked when I did:

save(list=ls(), 
     file =file.path("data","cachedData.Rda"))