tempdir()
#> [1] "/var/folders/0j/3g7q2zss7fb55q5wqg9t141r0000gn/T//RtmpNq1ZZL"
source("tempdir/showit.R")
#> Warning in file(filename, "r", encoding = encoding): cannot open file
#> 'tempdir/showit.R': No such file or directory
#> Error in file(filename, "r", encoding = encoding): cannot open the connection
dir(tempdir())
#> character(0)
where Rtmp0vv1wgj should persist across sessions. I'd need to take a deep look at help(tempfile) and play around a bit to feel confident because I'm not sure whether the approach is affected by the call to render taking place in a child environment.
I'm going to go with a different solution, which is to pass the objects (heaps of graphs) as a param, instead of passing the dataframe and creating the graphs in the Rmd document.