How to pass Rscript -e a multiline string? How to pass Rscript -e a multiline string? r r

How to pass Rscript -e a multiline string?


Update: I think the problem was spacing and quotes. This worked (on windows):

Rscript -e "a <- 3+3; cat(a,'\n')"6

On Mac, you have to escape the escape character:

Rscript -e 'a <- 3+3; cat(a,"\\n")'

You can also put each expression separately.

Rscript -e "a <- 3+3" -e "cat(a)"