├── .gitignore ├── README.md ├── basics ├── 01_absolute_basics.md ├── 02_signing_up.md ├── 03_clone_github_project.md ├── 04_pulling_project_updates.md ├── 05_navigating_RStudio_cloud.md └── 06_saving_permanent_copy.md ├── create_folder_structure.R ├── exercises ├── 01_run_some_basic_R.Rmd ├── 01_run_some_basic_R.html ├── 02_write_own_script_then_save.Rmd └── 02_write_own_script_then_save.html └── images ├── banner.png ├── deploying_project.png ├── download_export.png ├── download_from_github_website.png ├── export_processing.png ├── git_pull_main_screen.png ├── git_pull_updates_summary.png ├── log_out.png ├── new_project_git_link_entered.png ├── new_project_git_url.png ├── new_project_select.png ├── register_details.png ├── rstudio_cloud_first_load.png ├── rstudio_cloud_frontpage.png ├── rstudio_cloud_main_menu.png ├── rstudio_cloud_main_menu_2.png ├── rstudio_cloud_main_menu_select_rstudio_cloud_exercises.png ├── rstudio_cloud_main_project_exercises.png ├── rstudio_cloud_main_project_exercises_2.png ├── rstudio_cloud_main_project_knitting.png ├── rstudio_cloud_packages.png ├── rstudio_cloud_three_line_additional_menu.png ├── signup_cloud_free.png ├── what_is_git.png ├── what_is_github.png ├── what_is_r.png ├── what_is_rstudio.png └── your_projects_first_time.png /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # User-specific files 9 | .Ruserdata 10 | 11 | # Example code in package build process 12 | *-Ex.R 13 | 14 | # Output files from R CMD build 15 | /*.tar.gz 16 | 17 | # Output files from R CMD check 18 | /*.Rcheck/ 19 | 20 | # RStudio files 21 | .Rproj.user/ 22 | *.Rproj 23 | 24 | # produced vignettes 25 | vignettes/*.html 26 | vignettes/*.pdf 27 | 28 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 29 | .httr-oauth 30 | 31 | # knitr and R markdown default cache directories 32 | *_cache/ 33 | /cache/ 34 | 35 | # Temporary files created by R markdown 36 | *.utf8.md 37 | *.knit.md 38 | 39 | # R Environment Variables 40 | .Renviron 41 | 42 | # README html 43 | README.html 44 | 45 | #.DS_Store 46 | .DS_Store 47 | 48 | # essentials file 49 | essentials/ 50 | 51 | # basics html files 52 | basics/*.html 53 | 54 | # basics old b_01_absolute_basics file 55 | basics/01_absolute_basics.Rmd 56 | 57 | # basics old b_01_absolute_basics file 58 | exercises/01_absolute_basics.Rmd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Posit (RStudio) Cloud Tutorial for participants in Columbia Mailman SHARP Training 2 | 3 | ![](images/banner.png) 4 | 5 | ## Introduction 6 | 7 | Short guide on how to use the great features of RStudio Cloud in conjunction with SHARP Training courses.\ 8 | This guide assumes the user has functional knowledge of R and RStudio. 9 | 10 | Please first read through each of the md files in the [basics](#basics) folder to be able to create an Rstudio Cloud account, log in RStudio Cloud, and clone this GitHub repository (repo). 11 | 12 | Then perform a couple of simple exercises in RStudio Cloud in the [exercises](#exercises) folder through the cloned GitHub repository. 13 | 14 | Total time to complete tasks ~ 1-2 hours max. 15 | 16 | This tutorial is NOT a guide to learning R or RStudio in any great depth; there already countless fantastic guides out there!\ 17 | One example is the [RStudio Cloud Primers](https://rstudio.cloud/learn/primers). 18 | 19 | Robbie M Parks 2022. 20 | 21 | Thank you to Ahlam Abuawad, Tessa Bloomqvist, Anne Bozack, Vivian Do, Lukas Vlahos, and Abigail Welbourn for feedback. 22 | 23 | ## Contents of project by folder and script 24 | 25 | ### basics 26 | Folder with instructions for beginners to RStudio Cloud (to read through): 27 | 28 | [01_absolute_basics.md](/basics/01_absolute_basics.md) - markdown file to describe basics of potentially new concepts used for RStudio Cloud\ 29 | [02_signing_up.md](/basics/02_signing_up.md) - markdown file on how to sign up to RStudio Cloud\ 30 | [03_clone_github_project.md](/basics/03_clone_github_project.md) - markdown file on how to clone a GitHub project to Your Projects in RStudio Cloud\ 31 | [04_pulling_project_updates.md](/basics/04_pulling_project_updates.md) - markdown file on how to pull GitHub project updates which may have taken place during the SHARP course\ 32 | [05_navigating_RStudio_cloud.md](/basics/05_navigating_RStudio_cloud.md) - markdown file on how to navigate RStudio Cloud interface to select current project\ 33 | [06_saving_permanent_copy.md](/basics/06_saving_permanent_copy.md) - markdown file on how to make your edits to project and save permanent copy 34 | 35 | ### exercises 36 | Potentially useful exercises to do to further familiarise with RStudio Cloud (to go through in cloned GitHub repository in R Studio Cloud): 37 | 38 | [01_run_some_basic_R.Rmd](/exercises/01_run_some_basic_R.Rmd) - R Markdown script running some basic R on RStudio Cloud\ 39 | [02_write_own_script_then_save.Rmd](/exercises/02_write_own_script_then_save.Rmd) - R Markdown script to create simple script which can then be saved and downloaded as a part of a custom permanent copy 40 | 41 | ### File structure at the top of the project 42 | 43 | [basics](#basics) - folder with instructions for beginners to RStudio Cloud (full details above)\ 44 | [exercises](#exercises) - potentially useful exercises to do to further familiarise with RStudio Cloud (full details above)\ 45 | [images](/images) - folder with images used in markdown files\ 46 | [.gitignore](.gitignore) - this is usually in any project file and will tell Git/GitHub what to ignore locally with annoying stuff that sometimes get created\ 47 | [create_folder_structure.R](create_folder_structure.R) - script to initially create and define folder structure if not already there 48 | -------------------------------------------------------------------------------- /basics/01_absolute_basics.md: -------------------------------------------------------------------------------- 1 | # 01: Absolute basics of R, RStudio, RStudio Cloud, R Packages, Git, and GitHub 2 | 3 | ## What is R? 4 | 5 | R is an interactive environment developed by statisticians for data analysis.\ 6 | A more detailed Introduction to R can be found at https://www.r-project.org. \ 7 | Below is a sample screenshot of an R session on a local computer: 8 | 9 | ![](../images/what_is_r.png) 10 | 11 | ## What is RStudio? 12 | 13 | RStudio is an integrated development environment (IDE) for R developed by J J Allaire.\ 14 | RStudio provides a convenient graphical interface to R, making it more user-friendly, and providing many useful features.\ 15 | Such features include direct code execution, tools for plotting, history, debugging and workspace management.\ 16 | A more detailed background on to RStudio can be found at https://www.rstudio.com/about/. 17 | 18 | ![](../images/what_is_rstudio.png) 19 | 20 | ## What is RStudio Cloud? 21 | 22 | RStudio Cloud is a cloud-based RStudio which runs projects and code in the cloud.\ 23 | RStudio Cloud allows convenient scaling and sharing of code, including for training programs such as SHARP. \ 24 | Registration for free is available via https://rstudio.cloud/ \ 25 | We will go through how to navigate RStudio Cloud in the basics folder a littlle later in the tutorial. \ 26 | More details are available via https://rstudio.cloud/learn/guide. 27 | 28 | ![](../images/rstudio_cloud_first_load.png) 29 | 30 | ## What is an R package? 31 | 32 | An R package is an important and very common form of shareable code. A package is usually downloaded from the Comprehensive R Archive Network (CRAN), and is usually very easy to do in RStudio Cloud. Countless examples exist, including very famous examples such as [ggplot](https://epirhandbook.com/en/ggplot-basics.html) and [tidyverse](https://tidyverse.tidyverse.org/). When you first use an RStudio Cloud with a cloned GitHub project and start doing something, you will often see something like the yellow bar at the top of the window highlighted below asking if you want to install a package which is needed by a script but not currently installed on the R Studio Cloud project. The answer is almost always install. You can assume the answer will be yes throughout this tutorial. 33 | 34 | ![](../images/rstudio_cloud_packages.png) 35 | 36 | ## What is Git? 37 | 38 | This is just for information, as you will not be expected to be an expert on Git to participate in your SHARP course. 39 | 40 | Git is a widely used version control system. \ 41 | Version control, or source control, is the practice of tracking and managing changes to software code. \ 42 | Version control systems are software tools that help software teams manage changes to source code over time. \ 43 | In an academic context, it is useful to collaborate on a common project where you can all see the changes which are being made, and then there ends up being a master version once all suggested changes have been processed.\ 44 | For the SHARP workshops, Git will be used to clone a copy of the SHARP project to use throughout the training days.\ 45 | 46 | More details are available via https://www.codementor.io/git/tutorial/git-github-tutorial-for-beginners. 47 | 48 | ![](../images/what_is_git.png) 49 | 50 | ## What is GitHub? 51 | 52 | This is just for information, as you will not be expected to be an expert on GitHub to participate in your SHARP course. 53 | 54 | GitHub is a for-profit company which offers a cloud-based Git repository hosting service. \ 55 | For most people, Git and GitHub are interchangeable, but one is the version control system used (Git), and the other is the hosting service (GitHub). 56 | 57 | More details are available via https://www.codementor.io/git/tutorial/git-github-tutorial-for-beginners. 58 | 59 | ![](../images/what_is_github.png) 60 | 61 | ## You should now be ready to learn how to sign up to RStudio Cloud! 62 | 63 | Click link below for next tutorial 64 | 65 | [02_signing_up.md](https://github.com/rmp15/rstudio_cloud_tutorial/blob/main/basics/02_signing_up.md) 66 | -------------------------------------------------------------------------------- /basics/02_signing_up.md: -------------------------------------------------------------------------------- 1 | # 02: Signing up to RStudio Cloud 2 | 3 | ## The first step is to create a free RStudio Cloud account by visiting https://rstudio.cloud/ and clicking on 'Get Started For Free' to sign up (as detailed in the step-by-step images below): 4 | 5 | ![](../images/rstudio_cloud_frontpage.png) 6 | 7 | ## Now click on the Sign Up button: 8 | 9 | ![](../images/signup_cloud_free.png) 10 | 11 | ## Fill out your contact information and then click Sign Up to complete the sign-up process. It is recommended to use an email address that you will have access to for the foreseeable future: 12 | 13 | ![](../images/register_details.png) 14 | 15 | ## You will then be prompted to verify your email address via your email account. Once this is done, you should be able to log in and see something like this: 16 | 17 | ![](../images/your_projects_first_time.png) 18 | 19 | ## You should now be ready to learn how to clone a GitHub repository into RStudio Cloud! 20 | 21 | Click link below for next tutorial 22 | 23 | [03_clone_github_project.md](https://github.com/rmp15/rstudio_cloud_tutorial/blob/main/basics/03_clone_github_project.md) 24 | -------------------------------------------------------------------------------- /basics/03_clone_github_project.md: -------------------------------------------------------------------------------- 1 | # 03: Clone GitHub project to RStudio Cloud 2 | 3 | ## From signing up and logging in to Rstudio Cloud via https://rstudio.cloud/, you should see this page: 4 | 5 | ![image](../images/your_projects_first_time.png) 6 | 7 | ## Click on "New Project" and you should see several choices, including "New Project from Git Repository": 8 | 9 | ![](../images/new_project_select.png) 10 | 11 | ## Click on "New Project from Git Repository", you should see an invitation to enter a URL of your Git Repository: 12 | 13 | ![](../images/new_project_git_url.png) 14 | 15 | ## Enter https://github.com/rmp15/rstudio_cloud_tutorial into the box and click "OK" (your instructors for the selected SHARP training course will give you a similar specific link for you to use here): 16 | 17 | ![](../images/new_project_git_link_entered.png) 18 | 19 | ## You should see the "Deploying Project" screen for a time while the project copies from GitHub: 20 | 21 | ![](../images/deploying_project.png) 22 | 23 | ## You should then see a screen which looks a lot like an RStudio set-up on your local computer, but in your web browser and with an extra bar starting with 'Your Workspace': 24 | 25 | ![](../images/rstudio_cloud_first_load.png) 26 | 27 | ## You should now be ready to start using this GitHub repository in RStudio Cloud! 28 | 29 | Note: Some SHARP course instructors may create a GitHub repository in advance and share it with you before the first day of the course. They will let you know if that is the case. If so, you will be able to clone their GitHub project in the method described here. 30 | 31 | Click link below for next tutorial 32 | 33 | [04_pulling_project_updates.md](https://github.com/rmp15/rstudio_cloud_tutorial/blob/main/basics/04_pulling_project_updates.md) 34 | -------------------------------------------------------------------------------- /basics/04_pulling_project_updates.md: -------------------------------------------------------------------------------- 1 | # 04: Update GitHub project using Git pull 2 | 3 | ## SHARP training program instructors may make edits to the R projects after you’ve already saved the project to your RStudio or RStudio Cloud. As a result, they may ask you to 'pull' project updates during one of the sessions you attend. In this case, you should click 'git' in the top right window in the project view and then click on the 'pull' button, as highlighted below: 4 | 5 | ![](../images/git_pull_main_screen.png) 6 | 7 | ## All being well, you will be able to update the project, with a summary window showing what has been changed in the R Project (what is highlighted below is just a guide to what kind of information is expected to be seen, and not what is seen every time; that will change each time depending on which updates are pulled): 8 | 9 | ![](../images/git_pull_updates_summary.png) 10 | 11 | ## Note: There is also a Git 'push' button, which you will likely not need, but will be useful in saving to a GitHub project which you have administrative rights to modify (not this project but perhaps others): 12 | 13 | ![](../images/git_pull_main_screen.png) 14 | 15 | ## You can then continue with the training with the updated project! 16 | 17 | Click link below for next tutorial 18 | 19 | [05_navigating_RStudio_cloud.md](https://github.com/rmp15/rstudio_cloud_tutorial/blob/main/basics/05_navigating_RStudio_cloud.md) 20 | -------------------------------------------------------------------------------- /basics/05_navigating_RStudio_cloud.md: -------------------------------------------------------------------------------- 1 | # 05: Navigating RStudio Cloud menu 2 | 3 | ## Once you've logged in to your RStudio Cloud account after the very first time, you'll generally have a view of projects that you've copied over: 4 | 5 | ![](../images/rstudio_cloud_main_menu.png) 6 | 7 | ## You can click on the three horizontal lines in the top-left corner to open up a set of additional options, including creating additional Spaces (which may be useful for future reference but is outside the scope of this tutorial), and some useful general guides and primers: 8 | 9 | ![](../images/rstudio_cloud_three_line_additional_menu.png) 10 | 11 | ## If you want to log out of your account, click on your name in the top-right of the menu, then click on 'Log Out': 12 | 13 | ![](../images/log_out.png) 14 | 15 | ## Now you should be ready to learn how to save a permanent copy of the GitHub repository! 16 | 17 | Click link below for next tutorial 18 | 19 | [06_saving_permanent_copy.md](https://github.com/rmp15/rstudio_cloud_tutorial/blob/main/basics/06_saving_permanent_copy.md) 20 | -------------------------------------------------------------------------------- /basics/06_saving_permanent_copy.md: -------------------------------------------------------------------------------- 1 | # 06: Saving a permanent local copy 2 | 3 | ## At the end of the workshop, you may want to retain all of the edits and notes you made to the R scripts to use for reference later on. This can be done via the main menu, where you will see the download button highlighted below: 4 | 5 | ![](../images/rstudio_cloud_main_menu_2.png) 6 | 7 | ## Once you click on that, you will get an export processing window: 8 | 9 | ![](../images/export_processing.png) 10 | 11 | ## Once this is complete, you will be able to click on the 'Download' button to save a local copy of your edited project: 12 | 13 | ![](../images/download_export.png) 14 | 15 | ## We highly recommend saving everything at the end of the SHARP training, as you may have made several edits throughout the days. 16 | 17 | ## Note: You can also clone the GitHub repository directly from the GitHub project repository website (the one for this project is https://github.com/rmp15/rstudio_cloud_tutorial), but without your personal changes, which you can do by clicking on the blue Code button and clicking 'Download ZIP': 18 | 19 | ![](../images/download_from_github_website.png) 20 | 21 | ## You can now proceed to the exercises folder which will need to be done in your RStudio Cloud. On the RStudio Cloud log in main menu, click on the rstudio_cloud_tutorial project title: 22 | 23 | ![](../images/rstudio_cloud_main_menu_select_rstudio_cloud_exercises.png) 24 | 25 | ## Click on the exercises folder: 26 | 27 | ![](../images/rstudio_cloud_main_project_exercises.png) 28 | 29 | ## There are two exercises in this folder which you can go through by clicking on each of the exercises: 30 | 31 | ![](../images/rstudio_cloud_main_project_exercises_2.png) 32 | 33 | ## You may also notice that there are two additional files, one for each of the exercises highlighted above, with .html file endings. These files can be opened in a web browser to see the code in a convenient and readable way. This done via a process called 'knitting'. To create your own .html version, open an exercise and click on the 'knit' button highlighted below: 34 | 35 | ![](../images/rstudio_cloud_main_project_knitting.png) -------------------------------------------------------------------------------- /create_folder_structure.R: -------------------------------------------------------------------------------- 1 | # RStudio Cloud Tutorial for participants in Columbia Mailman SHARP Training 2 | # Robbie M Parks 2022 3 | 4 | # Script to initially create and define folder structure if not already there 5 | print('Creating folder structure') 6 | 7 | # load here package 8 | library(here) 9 | 10 | # declare directories 11 | project.folder <- paste0(here::here(),'/') 12 | basics.folder <- paste0(project.folder, "basics/") 13 | exercises.folder <- paste0(project.folder, "exercises/") 14 | images.folder <- paste0(project.folder, "images/") 15 | 16 | # identify list of folder locations which have just been created above 17 | folders.names <- grep(".folder",names(.GlobalEnv),value=TRUE) 18 | 19 | # create function to create list of folders 20 | # note that the function will not create a folder if it already exists 21 | create_folders <- function(name){ 22 | ifelse(!dir.exists(get(name)), dir.create(get(name), recursive=TRUE), FALSE) 23 | } 24 | 25 | # create the folders named above 26 | lapply(folders.names, create_folders) -------------------------------------------------------------------------------- /exercises/01_run_some_basic_R.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Run some basic R" 3 | output: 4 | html_document: 5 | toc: true 6 | toc_float: true 7 | editor_options: 8 | chunk_output_type: console 9 | --- 10 | 11 | ```{r setup, include=FALSE} 12 | knitr::opts_chunk$set(echo = TRUE) 13 | ``` 14 | 15 | ## Remove any potential lingering objects and data from RStudio when running a new script 16 | ```{r} 17 | rm(list=ls()) 18 | ``` 19 | 20 | ## Which R version am I using? 21 | ```{r} 22 | print(R.Version()) 23 | ``` 24 | 25 | ## Plot something 26 | 27 | ### Plot something using R base functionality 28 | ```{r} 29 | set.seed(1) 30 | x <- rnorm(100); y = rnorm(100) 31 | plot(x,y) 32 | ``` 33 | 34 | ### Plot something in R using ggplot 35 | ```{r} 36 | data <- data.frame(x,y) 37 | 38 | library(ggplot2) 39 | 40 | ggplot(data) + 41 | geom_point(aes(x=x,y=y)) + 42 | xlab('x-axis label') + ylab('y-axis label') + 43 | theme_classic() 44 | 45 | data <- NULL 46 | ``` 47 | 48 | ## Create numerical objects and make some simple operational manipulations and tests 49 | 50 | ### Create two numerical objects, a and b 51 | ```{r} 52 | a <- 11 53 | b <- 6 54 | ``` 55 | 56 | ### Addition of a and b 57 | ```{r} 58 | a+b 59 | ``` 60 | 61 | ### Subtraction of a and b 62 | ```{r} 63 | a-b 64 | ``` 65 | 66 | ### Multiplication of a and b 67 | ```{r} 68 | a*b 69 | ``` 70 | 71 | ### Division of a and b 72 | ```{r} 73 | a/b 74 | ``` 75 | 76 | ### Modulus (remainder of division) of a and b 77 | ```{r} 78 | a%%b 79 | ``` 80 | 81 | ### Raise a to the power of b 82 | ```{r} 83 | a^b 84 | ``` 85 | 86 | ### Is a less than b? 87 | ```{r} 88 | a