I am running a large course (~150 students) and would like to know what version students are using when they complete homework in Quarto. The first HW assignment is to get R/RStudio/R packages/tinytex/latex packages installed and render a Quarto document. I handled R installation issues on an ad hoc basis (and advised Posit Cloud usage for some). Instead of pestering 150 intro stats students to fill out a survey where they answer questions about how they installed R locally (or not, and might not know), I would include a code chunk like this for the TAs/graders to read on Gradescope (HW grading platform where students submit PDFs) to make sure everything is up-to-date and provide more targeted feedback if not.
c(paste0("R version is: ", R.Version()$major, ".", R.Version()$minor),
capture.output(sessionInfo())[2:3],
paste0("RStudio version is: ", rstudioapi::getVersion(), " running on ", rstudioapi::versionInfo()$mode),
paste0("Quarto version is: ", quarto::quarto_version()),
tinytex::tlmgr_version(),
substr(capture.output(rstudioapi::getSourceEditorContext())[3], 15, 1000))
Critically, rstudioapi::versionInfo()
, rstudioapi::getVersion()
, and rstudioapi::getSourceEditorContext()
only work in a session as Quarto is meant to be running in a clean R run, not dependent on RStudio. I couldn't figure out a way to get the RStudio version into a rendered Quarto PDF, so if anyone knows of a clever way to do this, that would be helpful.
Here's some example output:
This was a GitHub issue a few years ago: RStudio.Version() not functioning while knitting · Issue #6892 · rstudio/rstudio · GitHub
And also a community post before thatith even Jenny Bryan weighing in that it might be useful in other contexts.