Generates a project and repo for easy initialization of a GitHub repo for R workshops. The repo includes a README with instructions to ensure that all users have the needed packages, an 'RStudio' project with the right directories and the proper data. The repo can then be used for hosting code taught during the workshop.
Generates a project and repo for easy initialization of a workshop.
This is dependent on having a GitHub Personal Access Token (PAT).
First, go to GitHub user settings. Then click on
On the following page click
Personal Access Token.
Generate new token.
Finally, select the
The way some of the packages this package depends on are written, require that this code be saved in an environment variable. The best way to do this is to have a file named
.Renviron in your home directory which can be located with
Sys.getenv('HOME'). The file should look like this.
To create a project and turn it into a GitHub repo use the
If you have a list of data files stored somewhere that you want the user to download, build a
data.frame listing at least the local name to be used for the data, the URL where the data are stored and the mode to write the data such as 'w' or 'wb'. If you don't provide one, the default data stored in my data.world repo will be used. You should also specify a set of packages for the users to install.
data(datafiles, package='RepoGenerator')datafiles[, c('Local', 'Remote', 'Mode')]#> 1 DiamondColors.csv#> 2 diamonds.db#> 3 ExcelExample.xlsx#> 4 FavoriteSpots.json#> 5 flightPaths.csv#> 6 reaction.txt#> 7 ribalta.html#> 8 SocialComments.xml#> 9 TomatoFirst.csv#> 10 visited.csv#> 11 manhattan_Test.rds#> 12 manhattan_Train.rds#> 13 manhattan_Validate.rds#> 14 manhattan_Train.csv#> Remote Mode#> 1 w#> 2 wb#> 3 wb#> 4 w#> 5 w#> 6 w#> 7 w#> 8 - w#> 9 w#> 10 w#> 11 wb#> 12 wb#> 13 wb#> 14 w
packages <- c('caret', 'coefplot','DBI', 'dbplyr', 'doParallel', 'dygraphs','foreach', 'ggthemes', 'glmnet', 'jsonlite', 'leaflet', 'odbc','recipes', 'rmarkdown', 'rprojroot', 'RSQLite', 'rvest','tidyverse', 'threejs', 'usethis', 'UsingR', 'xgboost', 'XML','xml2')
createRepo(# the name to use for the repo and projectname='WorkshopExampleRepo',# the location on disc to build the projectpath='~/WorkshopExampleRepo',# the list of data files for the user to downloaddata=datafiles,# vector of packages the user should installpackages=packages,# the GitHub username to create the repo foruser='jaredlander',# the new repo's README has the name of who is organizing the classorganizer='Lander Analytics',# the name of the environment variable storing the GitHub PATtoken='MyGitHubPATEnvVar')
The earlier code created this repo on GitHub. You can point your attendees to the repo you created for easy instructions on getting ready for the workshop!