diff --git a/02-essentials/slides.html b/02-essentials/slides.html index a73cc3a..6131ba2 100644 --- a/02-essentials/slides.html +++ b/02-essentials/slides.html @@ -3042,25 +3042,25 @@

Table of contents

  • Naming, indexing, and filtering
  • Filtering vectors
  • If/Then Statements, Loops, and Functions (Control Statements)
  • Vectorizing and replicate
  • Session info
  • @@ -3486,8 +3486,8 @@

    Structures

    -
    -

    Questions 1

    +
    +

    Questions 1: Structures

    1. What structure would you want to perform a computationally-heavy task?

    2. What structure would you want to read in data from a colleague?

    3. @@ -3744,8 +3744,8 @@

      N

      In the last example, why is the dimension NULL? (Hint, what is the class of the last two examples?)

    -
    -

    Questions 2

    +
    +

    Questions 2: Naming objects

    1. What is the number of the alphabet for each letter of your name? Use a vector with names (try the `LETTERS’ object). For example, if the letters to the name JONATHAN were mapped to integers, the result would be: 10, 15, 14, 1, 20, 8, 1, 14.

    2. Why is it important extract elements through naming conventions?

    3. @@ -3997,8 +3997,8 @@

      Filtering vectors

      [1] FALSE
      -
      -

      Questions 3

      +
      +

      Questions 3: Filtering objects

      Suppose x is the number of vacations in the years 2010 - 2019

      set.seed(1)
      @@ -4138,8 +4138,8 @@ 

      Loops

      The next statement allows the loop to stop current iteration and continue to next iteration.

      -
      -

      Questions 4

      +
      +

      Questions 4: Creating a loop

      From Jan 1 - Jan 9, 2023, it snowed 6 days atop Snowbasin. Snow days can be represented each day in a vector as 1 (snow) and 0 (no snow).

      snow <- c(1,1,1,1,0,1,1,0,0)
      @@ -4205,8 +4205,8 @@ 

      Functions

      -
      -

      Questions 5

      +
      +

      Questions 5: Creating a function

      Generalize your code to Question 4 as a function so that for any string of days you can find the first day it consecutively snowed a given number of days. Return NA if no day meets this criteria.

      @@ -5171,7 +5171,7 @@

      Session info

      | **Usage** | Simple collections like numerical data | Mathematical computations, matrices | Grouping mixed-type data, complex structures | Tabular data, similar to Excel spreadsheets | -## Questions 1 +## Questions 1: Structures 1. What structure would you want to perform a computationally-heavy task? @@ -5336,7 +5336,7 @@

      Session info

      In the last example, why is the dimension `NULL`? (Hint, what is the class of the last two examples?) -## Questions 2 +## Questions 2: Naming objects 1. What is the number of the alphabet for each letter of your name? Use a vector with names (try the `LETTERS' object). For example, if the letters to the name JONATHAN were mapped to integers, the result would be: 10, 15, 14, 1, 20, 8, 1, 14. @@ -5478,7 +5478,7 @@

      Session info

      ``` -## Questions 3 +## Questions 3: Filtering objects Suppose `x` is the number of vacations in the years 2010 - 2019 ```{r, collapse=TRUE, comment=">"} @@ -5638,7 +5638,7 @@

      Session info

      The `next` statement allows the loop to stop current iteration and continue to next iteration. -## Questions 4 +## Questions 4: Creating a loop From Jan 1 - Jan 9, 2023, it snowed 6 days atop Snowbasin. Snow days can be represented each day in a vector as 1 (snow) and 0 (no snow). @@ -5727,7 +5727,7 @@

      Session info

      prop.table(table(tosses)) ``` -## Questions 5 +## Questions 5: Creating a function Generalize your code to Question 4 as a function so that for any string of days you can find the first day it consecutively snowed a given number of days. Return `NA` if no day meets this criteria. diff --git a/02-essentials/slides.qmd b/02-essentials/slides.qmd index 6b31ef7..26772c7 100644 --- a/02-essentials/slides.qmd +++ b/02-essentials/slides.qmd @@ -294,7 +294,7 @@ Data are stored in any of the following structures (starting from most primitive | **Usage** | Simple collections like numerical data | Mathematical computations, matrices | Grouping mixed-type data, complex structures | Tabular data, similar to Excel spreadsheets | -## Questions 1 +## Questions 1: Structures 1. What structure would you want to perform a computationally-heavy task? @@ -459,7 +459,7 @@ dim(x["2010",c("SLC","Milcreek")]) In the last example, why is the dimension `NULL`? (Hint, what is the class of the last two examples?) -## Questions 2 +## Questions 2: Naming objects 1. What is the number of the alphabet for each letter of your name? Use a vector with names (try the `LETTERS' object). For example, if the letters to the name JONATHAN were mapped to integers, the result would be: 10, 15, 14, 1, 20, 8, 1, 14. @@ -601,7 +601,7 @@ all(tx==1) ``` -## Questions 3 +## Questions 3: Filtering objects Suppose `x` is the number of vacations in the years 2010 - 2019 ```{r, collapse=TRUE, comment=">"} @@ -761,7 +761,7 @@ i The `next` statement allows the loop to stop current iteration and continue to next iteration. -## Questions 4 +## Questions 4: Creating a loop From Jan 1 - Jan 9, 2023, it snowed 6 days atop Snowbasin. Snow days can be represented each day in a vector as 1 (snow) and 0 (no snow). @@ -850,7 +850,7 @@ runs prop.table(table(tosses)) ``` -## Questions 5 +## Questions 5: Creating a function Generalize your code to Question 4 as a function so that for any string of days you can find the first day it consecutively snowed a given number of days. Return `NA` if no day meets this criteria.