I have created an R script that reads certain data from a file, calls the summary() method and then the plot() method.
But when I try to run the R script where the commands below are written, in the output file I get the summary, but not the graph.
When I run the following instructions in R manually, everything works perfectly, and I get both the summary and the graph.
Is there a way to get the graph in the output file?
m0<-read.csv(file="Myfile", head=FALSE, sep",")
var_m0<-c(m0$ V3)
summary(var_m0)
plot(var_m0)
Thanks!
You need to tell R what kind of output you want and where you want it to go. Take a look at
?pngfor a fairly comprehensive list. And don’t forgetdev.off()after yourplot()call!If you specifically want the graph in the same output file as the rest of the code, you can look at
knitrandsweave.