knitr include_graphics() cutting my image


So I am trying to import an image that I want to show full sized in R markdown via this code:


I have tried to change a variety of the option but I don't get it to work. The image shows but the full length of the image doesn't show.


ball <- readPNG("2017_2018downloadsR.png", native = TRUE)
plot(0:1, 0:1, type = "n", ann = FALSE, axes = FALSE)
rasterImage(ball, 0, 0, 1, 1)

Doing that code shows the full graph but it is so small. Image size is 1343 x 722 pixels.

Your image is getting cropped just in the source pane or in the knitted document as well?
I believe that what you see on the source pane is just a place holder (or a preview) for your image before it gets knitted to its final output, so maybe this behavior is by design.


I haven't tried to knit the document. I do intend to present it within Rmarkdown like this at the moment just given the big bits of data I want preloaded and issues with some of the outputs to knit. I'll have a check.

So after working on it again it displayed full for some reason. It was rather odd.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.