Search code examples
r-markdownmarkdowntiff

Is it possible to make RMarkdown HTML display tiff files?


I am trying to generate a report about some work I have been doing with geospatial data and I want to include tiff files I have generated for comparison. When I attempt to include the .tif files in the HTML RMarkdown output, it displays that "the format is not supported." How can I fix this? Is this a programming issue or a software issue?


Solution

  • You should consider the grid package, the tiff package and a code-chunk.

    1. You should make a code-chunk in Rmarkdown, filled with the instruction to read and print a.tif file.
    2. Assuming grid and tif packages are installed, the following code (in the code-chunk) do the printing task : grid::grid.raster( tiff::readTIFF( "./figure/myfigure.tif") )

    3. read the file in a code-chunk let you print a tif within knitting to any output format (including docx).

    Ps : Of course, you have to indicate a bunch of options for the code-chunk.