![]() ![]() First, the function is document format agnostic – meaning it can work with LaTeX or Markdown documents. We are using include_graphics for two reasons. img1_path ) or using markdown directly ( !(imagepath)). The raw image on disk has a width of 1000px and height of 667px (300 dpi). Library(png) # For grabbing the dimensions of png files Start by loading the packages library(knitr) # For knitting document and include_graphics function For example library(jpeg) readJPEG(img1). NOTE: you can use the same process to examine jpegs, simply swap out png for jpeg. Use the attr function: get the dimensions of the image as well as some other potentially useful information (color type, dpi, etc).Use the dim function: get the dimensions of the image.There are two ways to grab the dimensions (height and width) of the image. The image was downloaded to our local drive from here and can be used under the Creative Commons CC0 license.Īs a starting point, we can compute the dimensions of our raw image using the readPNG function from the package png. ![]() Moving forward we're going to refer to our uploaded image as image and the R-generated plot as figure. The plot is created using the package ggplot2. In this post we'll work with a pre-existing image as well as a dynamically generated plot. Our examples: one pre-existing image and one dynamically generated plot
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |