block by timelyportfolio 9e82ac7be40c070ae606

get all images from RStudio temp directory

RStudio achievement unlocked

Not sure if this might be useful to anyone but thought I would post it anyways. I thought it would be nice to be able to get all the images from the RStudio plots tab. On Windows, these are stored in tempdir(), so with some list.files, grepl, tag, and base64enc::dataURI, we could make an HTML page with all the charts. Where I think this will be most useful will be in an htmlwidget lightbox or something similar as an alternative and possibly more pleasant viewing experience.

library(htmltools)

html_print(lapply(
  list.files(tempdir(),"png",recursive=T,full.names=T)
  ,function(p){
    if(grepl(x=p,pattern="rs-graphics") && !(grepl(x=p,pattern="empty"))){
      tag("img",c(src=base64enc::dataURI(file=p)))
    }
  }
))

code.R