I am trying to produce a .png file with an R plot. This works great:
png(file="hello.png", width=1000, height=800)
# Lots and lots of plotting. Long code. Very slow.
plot(x=c(1, 2, 3), y=c(4, 6, 5))
dev.off()
Now how can I get a thumbnail of hello.png directly from R?
I’m not sure how this will scale to your real application and don’t have much experience with the
pnglibrary, but this worked reasonably quick on my test cases. You need to specify the name of the PNG file you want to make a thumbnail of and the height / width of that thumbnail. By default, it will save a thumbnail in the same directory withthumb_prepended to the file name.Let me know if this works for you. The function works well with
lapplyto operate on a large number of files in a directory at once as well:lapply(listOfFiles, makeThumb, height = 200, width = 200).