add_dog(dog_to_add = "German Shepard",
+add_dog(dog_to_add = "Akita",
input_vector = dog_breeds)
+## Already contains this dog
+add_dog(dog_to_add = "German Shepard",
+ input_vector = dog_breeds)
## [1] "German Shepard" "Labrador Retriever" "Akita"
## [4] "Bulldog"
+
+
+Poll 6
+What does this function do?
+mystery_function <- function(x) {
+ if (x > 0) {
+ return(x)
+ } else {
+ return(-x)
+ }
+}
+
+- Returns the absolute value of x
+- Returns x
+- Returns the square root of x
+- Returns -x
+
diff --git a/docs/Intro_to_R_data_analysis_part_2.html b/docs/Intro_to_R_data_analysis_part_2.html
index 799a650..48e5900 100644
--- a/docs/Intro_to_R_data_analysis_part_2.html
+++ b/docs/Intro_to_R_data_analysis_part_2.html
@@ -3862,7 +3862,7 @@ modified by adding layers
10 min break
-
+
diff --git a/intro-r-data-analysis/Intro_to_R_data_analysis_part_1.Rmd b/intro-r-data-analysis/Intro_to_R_data_analysis_part_1.Rmd
index 7b994e6..0c56716 100644
--- a/intro-r-data-analysis/Intro_to_R_data_analysis_part_1.Rmd
+++ b/intro-r-data-analysis/Intro_to_R_data_analysis_part_1.Rmd
@@ -35,8 +35,8 @@ Senior Statistician
**What is your level of experience with coding/data analysis?**
-1. I am fluent in another data analysis programming language (Python, Matlab etc.)
-2. I am use Excel to do linear regression
+1. I know another data analysis programming language (Python, Matlab etc.)
+2. I can use Excel to do linear regression
3. I know some R
4. All of the above
5. None of the above
@@ -119,6 +119,7 @@ feature rich graphical user interface (GUI)
- Let's create an `Rmd` file in `RStudio` to explore the basics of how they work:
- File -\> New File -\> R Markdown
+
## R Markdown Advanced Usage
- **Presentations:** Creating slides (like these) with [revealjs](https://github.com/rstudio/revealjs).
@@ -175,16 +176,26 @@ DogBreeds <- c("Labrador Retriever", "Akita", "Bulldog")
## Data Types
- Integer
- - Whole numbers
+ - Whole numbers (in R denote with L ex. 1L,2L)
- Numeric
- Decimal numbers
- Logical
- Boolean (TRUE, FALSE)
- - NA
+ - NA (missing data)
- Character
- Letters and strings of letters
- "A", "Labrador Retriever"
+## Poll 3
+
+**Which of these is not the correct data type for the value?**
+
+1. 1.5 - Numeric
+2. "Labrador Retriever" - Character
+3. NA - Logical
+4. 1 - Integer
+
+
## Data Structures
- Vectors
- Atomic vectors - one dimensional lists that store values of
@@ -197,7 +208,7 @@ DogBreeds <- c("Labrador Retriever", "Akita", "Bulldog")
- Data frames
- Columns and rows of **mixed types**
-##
+##

@@ -242,6 +253,19 @@ x >= y # Greater than or equal to
x %in% y # Is x in this vector y?
```
+## Poll 4
+
+**What is the output of the following code?**
+
+```{r, eval = FALSE}
+4 %in% as.character(c(1,2,3,4))
+```
+
+1. TRUE
+2. FALSE
+3. NA
+
+
## Logical Operators
- Logical operators can compare TRUE or FALSE values
```{r, eval=FALSE}
@@ -251,9 +275,22 @@ y <- FALSE
!x # Not x
x | y # x or y
x & y # x and y
-
```
+## Poll 5
+
+**What is the output of the following code?**
+```{r, eval=FALSE}
+x <- TRUE
+y <- FALSE
+
+x & !y
+```
+
+1. TRUE
+2. FALSE
+3. NA
+
## Conditional execution
- Relational and logical operations allow for conditional
@@ -308,6 +345,27 @@ add_dog(dog_to_add = "German Shepard",
input_vector = dog_breeds)
```
+## Poll 6
+
+**What does this function do?**
+
+```{r, eval = FALSE}
+mystery_function <- function(x) {
+ if (x > 0) {
+ return(x)
+ } else {
+ return(-x)
+ }
+}
+```
+
+1. Returns the absolute value of x
+2. Returns x
+3. Returns the square root of x
+4. Returns -x
+
+
+
# Packages
## Packages