Hello, Have you tried
source("script.r", print.eval = TRUE) ? Also, you should print() the graph explicitly: library(ggplot2) data(midwest, package = "ggplot2") g <- ggplot(midwest, aes(area, poptotal)) + geom_point() print(g) Hope this helps, Rui Barradas Às 16:32 de 24/01/20, Felix Blind escreveu:
Dear R users, i am a python user trying to get my statistical knowledge up to speed and R is the language for that. I would like to run R scripts like that: R -f script.r and still get the plots that pop up. When I type the following code in the R REPL I get a nice plot: library(ggplot2) data("midwest", package="ggplot2") ggplot(midwest, aes(x=area, y=poptotal)) + geom_point() But when I put the same code in a file script.r and run it with R -f script.r or if I source it in the REPL with source("script.r") I do not get any plots shown. Can you guys tell me what I do wrong. (Apart from either using RStudio or the REPL exclusively) Kind regards, Felix ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.