I am getting ready to teach intro R labs, and my students need to be able to make stand-alone jpg images of their plots. Because it's an intro class, I was planning to have them switch their RStudio preferences to uncheck "show output inline," so plots would show up in the Plots pane and have the Export button available.
But, unchecking that box undoes the working directory magic that allows you to use relative paths from the point of view of the RMarkdown document, and returns the working directory to the main project directory. Is there a way these two options could be decoupled?
Alternatively, could there be a way to jump a plot from the inline preview to the Plots pane to be able to use the Export button?
It would be interesting if your students could make their reports in Rmd. Explain the simple part of each chunk (code and comment). That way they can make reports and make comments before or after each image. Maybe in HTLM.
At the end, instead of saving the images of each class, they can have a report in rmd with comments that can help after the subject is finished.
Yes, in past semesters I have had all students submit their knitted HTML documents. However, this semester I am one of many instructors using a standardized lab assignment in our learning management software (Specially, the assignment is a Canvas "quiz"). So, they need to be able to get their images separately.
I haven't dug into this more, but I'm now wondering if the here package would be the solution. Then the document could declare here::i_am(), the filepaths to the data could be with here(), and I could have students uncheck "show output inline."
IIUC you want them to work in an Rmd but then also have access to the generated plots as individual images, is that correct? If so, you could change the output to github_document in the YAML and this will generate the files separately (since it's no longer a self-contained html). Then, if the Rmd's name is lab1.Rmd the files will live in a lab1_filesfolder. And if they use proper chunk labels, the files will be named after the chunk label (followed by -1 for a reason I don't know). Does that resolve things?
Thanks, that's so clever! I should have thought about that, I'm making students in other classes use github_documents. I did something that was functionally the same (added fig.path='plots/' to the knitr::opts_chunk$set). But I'm still wishing for the ability to run code in the RMarkdown document but somehow get the plots into the Plots pane.
You might already know this, and it doesn't address your original question but just in case it's helpful -- when interactively running that's possible with [gear icon next to knit] > Chunk output in Console, and then you get the plots there when you run each chunk. It doesn't address the issue of saving plots though.
If you meant a way to knit a document and see all of the plots in that document in the plotting pane, I don't think that's possible, but also I don't see how it would be desired, given a document can have many plots?