Copying packages and environment in Assignments

Hi -

I'm using Rstudio Cloud to teach intro stats for the first time. I had students download RStudio last year, but faced constant 'tech support' issues with packages and data imports not working. I decided to use the Cloud version this year so I could set everything up for the students in advance.

So, I set up a shared space for my class and created an initial project that I designated as an Assignment. I installed a couple of packages (dplyr, ggplot2) and then loaded them with the 'library' command. I also loaded some stuff into the global environment (one data frame, which I then "attached" so the variables could be referenced by name without the $ convention, and a few generic vectors).

When students accessed the assignment today, thereby creating their own copies of the project, none of the items in the global environment were copied over, and the packages were installed but not loaded (i.e. no check mark by their names). Is this normal? I assumed everything would copy over.

If this is normal behavior for RStudio Cloud's 'assignments' feature, what can I do to most effectively accomplish my goal of having everything set up when students start an assignment (so they don't have to do any loading of packages or data)? I could not find anything on this topic in the community forum.

Thanks for your help.

This is indeed normal behaviour, though I completely understand the desire for this feature. It's in the spirit of preparing everything for the student and letting them drop in to the assignment at a stage you decide. That being said, there is a good reproducibility argument against sharing the global environment in this way.

A few options:

  • If you use R Markdown, you can include these in a chunk on top of the document so students can knit the document and start where you want them to get started.
  • If not, you can include an R script doing the same.

Another option is to add a .Rprofile so the code here is run when the project is launched. However I would advise against doing much in here beyond loading the packages. Any computing for creating the vectors etc. should live in an R script/R Markdown document. This adds transparency to the work, and will not leave students wondering where they came from.

1 Like