Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate the option of using use_course #120

Open
luisesanmartin opened this issue Apr 26, 2023 · 3 comments
Open

Evaluate the option of using use_course #120

luisesanmartin opened this issue Apr 26, 2023 · 3 comments

Comments

@luisesanmartin
Copy link
Member

Reference: https://www.rdocumentation.org/packages/usethis/versions/1.3.0/topics/use_course

Could potentially avoid having participants looking for file paths or using path locations

@mfiorina
Copy link
Contributor

Reposted from Slack for trackability:
We talked about potential using usethis::use_course() to set up the R environment for students. I can work up a proposal for this specific course, but wanted to share what I do for the SAIS course and see if people think this’ll work/have suggestions about it:

In the slides (to which the students have access through a link), I initially ask them to do the following:

  • Open RStudio.
  • Type in the following lines, replacing “YOURFILEPATHHERE” with a file path where these files will be saved.
    • For MacBook users, this could be “/Users/marc-andreafiorina/Desktop/”
    • For Windows users, this could be “C:/Users/marc-andreafiorina/Desktop/”
install.packages("usethis")
library(usethis)
usethis::use_course(
    "https://github.com/mfiorina/sais_r_course/archive/main.zip",
    destdir = "YOURFILEPATHHERE"
)

The use_course() function downloads the GitHub repo as a folder within the destination directory provided by the student, then asks them through interaction (type in “1” for yes, “2" for no into the console) whether they want to delete the .zip file, and then opens up a new RStudio environment with the correct .Rproj file already set up.
In my course, the data is too big to be included in this step, so in the initial script I provide for the students to work through, they download the data into the project using the following code:

# This is session 1 so we're going to import the data from Dropbox:
  
  if(!(file.exists("data/final/wvs_values_norms_data.csv"))) { # Checks whether the data has been downloaded already
      usethis::use_zip(
          "https://www.dropbox.com/scl/fo/vnxjbqyq1g9z368coh1vq/h?rlkey=zc66o2ll7613b5e9ipp915ynk&dl=1"
      )
  }

The folder is called “data” so it effectively creates a “data” folder within their project with the correct data. We don’t have to do this if the data is loaded initially with the GitHub repo, which I think we want to do.

So for this course we could do the same instead of asking students to create their own .Rproj file. The benefit is consistency (it really really cut down on time I spent helping students set up), a possible drawback is that the students may not be as comfortable setting up their own RStudio environment outside of the course. I think it’s worth it as long as we also show them how to do it themselves initially, which is what I now do during the SAIS course.

@mfiorina
Copy link
Contributor

Suggested use for this course:
Screen Shot 2024-02-23 at 10 42 24 AM

@mfiorina
Copy link
Contributor

mfiorina commented Mar 6, 2024

Note after first attempt to use during course: I've discovered an option to automatically delete the .zip file. For some reason it isn't available for usethis::use_course(), but it is available for usethis::use_zip(), which does exactly the same thing.

The code would look like:

usethis::use_zip(
    "https://github.com/worldbank/dime-r-training/archive/main.zip",
    destdir = "FILEPATHHERE", cleanup = TRUE
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants