diff --git a/01-lesson1.Rmd b/01-lesson1.Rmd index cca383b..313988e 100644 --- a/01-lesson1.Rmd +++ b/01-lesson1.Rmd @@ -1,7 +1,5 @@ # Intro to Computing -*Slides that go with this lesson can be found [here](slides/lesson1_slides.html).* - ## Goals of the course - Fundamental concepts in high-level programming languages (R, Python, Julia, WDL, etc.) that is transferable: *How do programs run, and how do we solve problems using functions and data structures?* @@ -95,7 +93,7 @@ For instance, consider the following expressions entered to the R Console: max(18, 21) max(18 + 21, 65) 18 + (21 + 65) -length("ATCG") +nchar("ATCG") ``` Here, our input **data types** to the operation are **numeric** in lines 1-4 and our input data type to the function is **character** in line 5. @@ -120,6 +118,18 @@ If an expression is made out of multiple, nested operations, what is the proper Lastly, a note on the use of functions: a programmer should not need to know how the function is implemented in order to use it - this emphasizes [abstraction and modular thinking](#a-programming-language-has-following-elements), a foundation in any programming language. + +### Data types + +Here are some data types that we will be using in this course: + +- **Numeric**: 18, 21, 65, 1.25 + +- **Character**: "ATCG", "Whatever", "948-293-0000" + +- **Logical**: TRUE, FALSE + + ## Grammar Structure 2: Storing data types in the global environment To build up a computer program, we need to store our returned data type from our expression somewhere for downstream use. We can assign a variable to it as follows: @@ -166,26 +176,6 @@ sqrt(nchar("hello")) (nchar("hello") + 4) * 2 ``` -## Functions to read in data - -We are going to read in a Comma Separated Value (CSV) spreadsheet, that contains information about cancer cell lines. - -The first line calls the function `read.csv()` with a string argument representing the file path to the CSV file (we are using an URL online, but this is typically done locally), and the returned data type is stored in `metadata` variable. The resulting `metadata` variable is a new data type you have never seen before. It is a **data structure** called a **data frame** that we will be exploring next week. It holds a table of several data types that we can explore. - -We run a few functions on `metadata`. - -```{r} -metadata = read.csv("https://github.com/caalo/Intro_to_R/raw/main/classroom_data/CCLE_metadata.csv") -head(metadata) -nrow(metadata) -ncol(metadata) -``` - -If you don't know what a function does, ask for help: - -```{r} -?nrow -``` ## Tips on Exercises / Debugging diff --git a/index.Rmd b/index.Rmd index cd5c2b0..a2db556 100644 --- a/index.Rmd +++ b/index.Rmd @@ -1,5 +1,5 @@ --- -title: "Season 1 Introduction to R" +title: "Introduction to R, Season 1" date: "`r format(Sys.time(), '%B, %Y')`" site: bookdown::bookdown_site documentclass: book diff --git a/slides/lesson1_slides.html b/slides/lesson1_slides.html index 247e9a3..c6c46fc 100644 --- a/slides/lesson1_slides.html +++ b/slides/lesson1_slides.html @@ -420,7 +420,7 @@

Introductions

Goals of the course

@@ -491,7 +491,7 @@

Format of the course

@@ -531,21 +531,11 @@

A programming language has following themes:

  • Means of abstraction for modular and reusable content (data structures, functions)
  • -
    - -

    What is R and why should I use it?

    -
    -
    -
    @@ -557,10 +547,11 @@

    What is R and why should I use it?

    Setting up Posit Cloud and trying out your first analysis!

    -

    link here

    Break

    +

    Let’s find times for office hours, as well as time for people to work together!

    +

    https://www.when2meet.com/?21640707-kwIMj

    Grammar Structure 1: Evaluation of Expressions

    @@ -571,7 +562,7 @@

    Grammar Structure 1: Evaluation of Expressions

    @@ -622,11 +613,11 @@

    Examples

    -
    length("ATCG")
    +
    nchar("ATCG")
    -
    [1] 1
    +
    [1] 4
    -
    -

    Data types

    - -

    Function machine from algebra class

    @@ -692,6 +675,14 @@

    Function machine from algebra class

    }
    +
    +

    Data types

    + +

    Grammar Structure 2: Storing data types in the global environment

    @@ -772,7 +763,7 @@

    Grammar Structure 3: Evaluation of Functions

    Execution rule for functions:

    -

    Evaluate the function by its arguments, and if the arguments are functions or contains operations, evaluate those functions or operations first.

    +

    Evaluate the function by its arguments, and if the arguments contain expressions, evaluate those expressions first.

    The output of functions is called the returned value.

    diff --git a/slides/lesson1_slides.qmd b/slides/lesson1_slides.qmd index c13f1c5..f2af109 100644 --- a/slides/lesson1_slides.qmd +++ b/slides/lesson1_slides.qmd @@ -1,8 +1,8 @@ --- title: "W1: Intro to Computing" format: revealjs - smaller: true - scrollable: true + #smaller: true + #scrollable: true execute: echo: true output-location: fragment @@ -30,7 +30,7 @@ output-location: fragment . . . -- Fundamental concepts in high-level programming languages: *How do programs run, and how do we solve problems using functions and data structures?* +- Fundamental concepts in programming languages: *How do programs run, and how do we solve problems effectively using functions and data structures?* . . . @@ -79,7 +79,7 @@ output-location: fragment . . . -- Certification quiz at the end of the course +- Certification at the end of the course ## What is a computer program? @@ -125,10 +125,13 @@ More importantly: **How we organize ideas \<-\> Instructing a computer to do som ## Setting up Posit Cloud and trying out your first analysis! -link here ## Break +Let's find times for office hours, as well as time for people to work together! + +https://www.when2meet.com/?21640707-kwIMj + ## Grammar Structure 1: Evaluation of Expressions . . . @@ -137,7 +140,7 @@ link here . . . -- Operations and functions combine **data types** to return another data type. +- Operations and functions take in **data types** and return another data type. . . . @@ -170,20 +173,13 @@ max(18 + 21, 65) . . . ```{r} -length("ATCG") +nchar("ATCG") ``` ::: notes If an expression is made out of multiple, nested operations, what is the proper way of the R Console interpreting it? Being able to read nested operations and nested functions as a programmer is very important. ::: -## Data types - -- **Numeric**: 18, 21, 65, 1.25 - -- **Character**: "ATCG", "Whatever", "948-293-0000" - -- **Logical**: TRUE, FALSE ## Function machine from algebra class @@ -209,6 +205,15 @@ sum(18, sum(21, 65)) Lastly, a note on the use of functions: a programmer should not need to know how the function is implemented in order to use it - this emphasizes abstraction and modular thinking, a foundation in any programming language. ::: +## Data types + +- **Numeric**: 18, 21, 65, 1.25 + +- **Character**: "ATCG", "Whatever", "948-293-0000" + +- **Logical**: TRUE, FALSE + + ## Grammar Structure 2: Storing data types in the global environment . . . @@ -263,7 +268,7 @@ A function has a **function name**, **arguments**, and **returns** a data type. ::: callout-tip ## Execution rule for functions: -Evaluate the function by its arguments, and if the arguments are functions or contains operations, evaluate those functions or operations first. +Evaluate the function by its arguments, and if the arguments contain expressions, evaluate those expressions first. The output of functions is called the **returned value**. :::