Is it possible to run R script from terminal and get created variables in RStudio environment

I would like to use Makefile to run some R script (from terminal) and then get the created variables in RStudio environment.
Is this possible? What are my options besides sourcing the file from console?

you can save and load r objects with saveRDS and readRDS,
you can save an entire workspace with save.image

Can you present an example?
Let's say I have a script a.R that includes:

a <- "This is a."

And now I call it from a terminal by using Rscript a.R. So if I understand correctly I need to use saveRDS(a, "rds_file.rds") and call readRDS("rds_file.rds") from RStudio?
This seems more complicated than just source("a.R"). :confused:

You'ld need quote marks...


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.