Next chart
pdf("test.pdf") p <- qplot(hp, mpg, data=mtcars, color=am, xlab="Horsepower", ylab="Miles per Gallon", geom="point") p dev.off()
works in the console, but not in a function or when you send it from a file.
myfunc <- function() { p <- qplot(hp, mpg, data=mtcars, color=am, xlab="Horsepower", ylab="Miles per Gallon", geom="point") p } pdf("test.pdf") myfunc() dev.off()
Will create a damaged pdf file and a way to fix it.
print(p)
inside the function.
In the console. "p" is automatically printed, but not in the function or in the source file.
user7732049 Mar 18 '17 at 15:43 2017-03-18 15:43
source share