-
Notifications
You must be signed in to change notification settings - Fork 1
R and rstudio intermediate #20
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
Open
cathy-y
wants to merge
36
commits into
main
Choose a base branch
from
r-and-rstudio-intermediate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
1bc8755
Move file from master to individual branch
stephan-koenig 3100f3b
Fix text formatting and add donwload link for data
stephan-koenig 09c6fca
Apply suggestions from TA code review
stephan-koenig 5d9bcbb
Apply suggestions from code review
cathy-y a6ab1b7
Apply suggestions from code review
cathy-y 53f8905
Fixed markups for code chunks
cathy-y 4d92829
Restructured order of sections, moved learning objectives to the begi…
cathy-y d5f518b
Update r_and_rstudio_basic.html
cathy-y 4f3e598
Rewrote questions (and uploaded images to go with them)
cathy-y 2187691
Question revisions
cathy-y 7267170
Removed the working with data section
cathy-y 9c8116b
Changed capitalization
cathy-y 1d952f5
Added section on data types, amended questions
cathy-y 88bf430
Update inst/tutorials/r_and_rstudio_basic/r_and_rstudio_basic.Rmd
cathy-y 9c93172
Added section on vectors and data frames, covered logical operators i…
cathy-y 64ffef4
Started the troubleshooting section
cathy-y 5a98376
Completed getting help section
cathy-y 493826e
Edited the troubleshooting section
cathy-y ee6ba8e
Added internal links
cathy-y a9ca887
Updated internal links
cathy-y 51db6d0
Added review questions and drafted learning objectives
cathy-y 6a08bd8
Add to IntroR review questions
6821e3b
I need to pull from Github and it won't let me do it until I commit
cathy-y 1d3f967
Merge branch 'r-and-rstudio-intermediate' of https://github.com/EDUCE…
cathy-y f43b246
Drafted part of the section on writing functions
cathy-y ddadcbe
Fleshed out Functions and started helper functions
cathy-y ecba69e
Added section on transforming data
cathy-y 3fdbbf2
Merge branch 'main' into r-and-rstudio-intermediate
cathy-y 1d3efd3
Merge branch 'main' into r-and-rstudio-intermediate
stephan-koenig 0b4e881
Added sapply section
cathy-y deea0d7
Added section on removing NAs
cathy-y e140767
Added section on tidying data
cathy-y 948f4c4
Added questions to tidying data and started joining data
cathy-y 61fd076
Added section on joins
cathy-y 7d47b5d
Finished section on joins
cathy-y 662bfd9
Merge branch 'main' into r-and-rstudio-intermediate
stephan-koenig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ Imports: | |
learnr, | ||
readr, | ||
shiny | ||
RoxygenNote: 7.1.0 | ||
RoxygenNote: 7.1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron") | ||
if (!require(devtools)) install.packages("devtools") | ||
remove.packages("devtools") | ||
myPaths <- .libPaths() | ||
myPaths <- c(myPaths[2], myPaths[1]) | ||
.libPaths(myPaths) | ||
.libPaths() | ||
myPaths <- .libPaths() | ||
myPaths <- c(myPaths, "C:/CustomR") | ||
.libPaths(myPaths) | ||
devtools::install_github("EDUCE-UBC/educer") | ||
1 | ||
library("dplyr") | ||
library("learnr") | ||
library("readr") | ||
library("tidyverse") | ||
install.packages("tidyverse") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions
139
inst/tutorials/r_and_rstudio_intermediate/r_and_rstudio_intermediate.Rmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
--- | ||
title: "Intermediate R and RStudio" | ||
author: "Cathy Yan" | ||
date: "version `r format(Sys.time(), '%B %d, %Y')`" | ||
output: | ||
learnr::tutorial: | ||
progressive: true | ||
allow_skip: true | ||
runtime: shiny_prerendered | ||
description: [DESCRIPTION] | ||
--- | ||
|
||
```{r setup, include = FALSE} | ||
# General learnr setup | ||
library(learnr) | ||
knitr::opts_chunk$set(echo = TRUE) | ||
library(educer) | ||
# Helper function to set path to images to "/images" etc. | ||
setup_resources() | ||
|
||
# Tutorial specific setup | ||
library(dplyr) | ||
library(readr) | ||
library(tidyverse) | ||
``` | ||
|
||
## Learning objectives | ||
|
||
Here's what you'll learn from each section of this tutorial: | ||
|
||
Loops in R: | ||
|
||
- Explain the mechanisms of for and while loops | ||
- Implement for and while loops | ||
- Recognize and understand how nested loops work | ||
|
||
Conditionals in R: | ||
|
||
- Write and evaluate and/or statements | ||
- Identify the components of if/else statements | ||
- Implement conditionals within loops | ||
|
||
Functions in R: | ||
|
||
- Write functions that operate on arguments | ||
- Understand the role of helper functions | ||
- Implement helper functions | ||
|
||
Manipulating Data Frames: | ||
|
||
- Implement the pipe operator | ||
- Use the `select()`, `filter()`, and `mutate()` functions appropriately | ||
- Operate on individual columns within a data frame | ||
- Change the data type of columns in a data frame | ||
- Replace NAs in a vector or data frame | ||
|
||
Other ideas: Tidying data, joining data frames, loading in data from an external source | ||
|
||
## Review | ||
|
||
Before proceeding, complete the five questions below reviewing content from Introduction to R and RStudio Fundamentals. If any of the concepts seem unfamiliar, please revisit the previous tutorial. | ||
|
||
```{r using-libraries, echo=FALSE} | ||
quiz(question("In no particular order, which actions are required before using functions from a new package?", | ||
answer("Install the package", correct=TRUE), | ||
answer("Download vignettes"), | ||
answer("Load the package", correct=TRUE), | ||
answer("Install dependencies")) | ||
) | ||
``` | ||
|
||
Pull up the help page for the function `quantile()`. | ||
|
||
```{r q-help, exercise=TRUE} | ||
# your code here | ||
``` | ||
|
||
```{r q-help-solution} | ||
?quantile | ||
``` | ||
|
||
```{r review, echo=FALSE} | ||
quiz( | ||
question("What types of arguments can be passed to `quantile()`?", | ||
answer("Logical", correct=TRUE), | ||
answer("Numeric", correct=TRUE), | ||
answer("Logical Vector"), | ||
answer("Numeric Vector", correct=TRUE), | ||
answer("Text")) | ||
) | ||
``` | ||
|
||
Create a vector with the numbers 9, 27, 15, 74, 36, 4, and 49 and assign it to the variable `x`. Calculate the quantiles for `x`. | ||
|
||
```{r q-vector, exercise=TRUE} | ||
# your code here | ||
``` | ||
|
||
```{r q-vector-hint-1} | ||
x <- c(9, 27, 15, 74, 36, 4, 49) | ||
``` | ||
|
||
```{r q-vector-solution} | ||
x <- c(9, 27, 15, 74, 36, 4, 49) | ||
quantile(x) | ||
``` | ||
|
||
```{r q-type1, echo=FALSE} | ||
quiz( | ||
question("What is the 75% quantile for `x`?", | ||
answer("36"), | ||
answer("50.25"), | ||
answer("42.5", correct=TRUE)) | ||
) | ||
``` | ||
|
||
```{r q-type7, echo=FALSE} | ||
quiz( | ||
question("what is the 25% quantile for `x` if argument type = 1? ", | ||
answer("27"), | ||
answer("12"), | ||
answer("15"), | ||
answer("9", correct = TRUE)) | ||
) | ||
``` | ||
```{r q-25, echo=FALSE} | ||
quiz( | ||
question("what is the 25% quantile for `x` if argument type = 7? ", | ||
answer("27"), | ||
answer("9"), | ||
answer("15"), | ||
answer("12", correct = TRUE)) | ||
) | ||
|
||
``` | ||
|
||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguments may be difficult to follow for new users. The probs argument has a seq function that was not covered in the workshop