Skip to content

Commit

Permalink
Merge fa5431d into e861d18
Browse files Browse the repository at this point in the history
  • Loading branch information
caalo authored Sep 29, 2023
2 parents e861d18 + fa5431d commit 5d1dd04
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 64 deletions.
36 changes: 13 additions & 23 deletions 01-lesson1.Rmd
Original file line number Diff line number Diff line change
@@ -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?*
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion index.Rmd
Original file line number Diff line number Diff line change
@@ -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
Expand Down
41 changes: 16 additions & 25 deletions slides/lesson1_slides.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ <h2>Introductions</h2>
<h2>Goals of the course</h2>
<div class="fragment">
<ul>
<li>Fundamental concepts in high-level programming languages: <em>How do programs run, and how do we solve problems using functions and data structures?</em></li>
<li>Fundamental concepts in programming languages: <em>How do programs run, and how do we solve problems effectively using functions and data structures?</em></li>
</ul>
</div>
<div class="fragment">
Expand Down Expand Up @@ -491,7 +491,7 @@ <h2>Format of the course</h2>
</div>
<div class="fragment">
<ul>
<li>Certification quiz at the end of the course</li>
<li>Certification at the end of the course</li>
</ul>
</div>
</section>
Expand Down Expand Up @@ -531,21 +531,11 @@ <h2>A programming language has following themes:</h2>
<li>Means of abstraction for modular and reusable content (data structures, functions)</li>
</ul>
</div>
<div class="fragment">
<ul>
<li>Culture (emphasis on open-source, collaborative, reproducible code)</li>
</ul>
</div>
</section>
<section id="what-is-r-and-why-should-i-use-it" class="slide level2">
<h2>What is R and why should I use it?</h2>
<div class="fragment">
<ul>
<li>Dynamic programming interpreter</li>
</ul>
</div>
<div class="fragment">
<ul>
<li>Highly used for data science, visualization, statistics, bioinformatics</li>
</ul>
</div>
Expand All @@ -557,10 +547,11 @@ <h2>What is R and why should I use it?</h2>
</section>
<section id="setting-up-posit-cloud-and-trying-out-your-first-analysis" class="slide level2">
<h2>Setting up Posit Cloud and trying out your first analysis!</h2>
<p>link here</p>
</section>
<section id="break" class="slide level2">
<h2>Break</h2>
<p>Let’s find times for office hours, as well as time for people to work together!</p>
<p>https://www.when2meet.com/?21640707-kwIMj</p>
</section>
<section id="grammar-structure-1-evaluation-of-expressions" class="slide level2">
<h2>Grammar Structure 1: Evaluation of Expressions</h2>
Expand All @@ -571,7 +562,7 @@ <h2>Grammar Structure 1: Evaluation of Expressions</h2>
</div>
<div class="fragment">
<ul>
<li>Operations and functions combine <strong>data types</strong> to return another data type.</li>
<li>Operations and functions take in <strong>data types</strong> and return another data type.</li>
</ul>
</div>
<div class="fragment">
Expand Down Expand Up @@ -622,11 +613,11 @@ <h2>Examples</h2>
</div>
<div class="fragment">
<div class="cell">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1"></a><span class="fu">length</span>(<span class="st">"ATCG"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1"></a><span class="fu">nchar</span>(<span class="st">"ATCG"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell fragment">
<div class="cell-output cell-output-stdout">
<pre><code>[1] 1</code></pre>
<pre><code>[1] 4</code></pre>
</div>
</div>
<aside class="notes">
Expand All @@ -644,14 +635,6 @@ <h2>Examples</h2>
}</style></aside>
</div>
</section>
<section id="data-types" class="slide level2">
<h2>Data types</h2>
<ul>
<li><p><strong>Numeric</strong>: 18, 21, 65, 1.25</p></li>
<li><p><strong>Character</strong>: “ATCG”, “Whatever”, “948-293-0000”</p></li>
<li><p><strong>Logical</strong>: TRUE, FALSE</p></li>
</ul>
</section>
<section id="function-machine-from-algebra-class" class="slide level2">
<h2>Function machine from algebra class</h2>
<div class="fragment">
Expand Down Expand Up @@ -692,6 +675,14 @@ <h2>Function machine from algebra class</h2>
}</style></aside>
</div>
</section>
<section id="data-types" class="slide level2">
<h2>Data types</h2>
<ul>
<li><p><strong>Numeric</strong>: 18, 21, 65, 1.25</p></li>
<li><p><strong>Character</strong>: “ATCG”, “Whatever”, “948-293-0000”</p></li>
<li><p><strong>Logical</strong>: TRUE, FALSE</p></li>
</ul>
</section>
<section id="grammar-structure-2-storing-data-types-in-the-global-environment" class="slide level2">
<h2>Grammar Structure 2: Storing data types in the global environment</h2>
<div class="fragment">
Expand Down Expand Up @@ -772,7 +763,7 @@ <h2>Grammar Structure 3: Evaluation of Functions</h2>
<p><strong>Execution rule for functions:</strong></p>
</div>
<div class="callout-content">
<p>Evaluate the function by its arguments, and if the arguments are functions or contains operations, evaluate those functions or operations first.</p>
<p>Evaluate the function by its arguments, and if the arguments contain expressions, evaluate those expressions first.</p>
<p>The output of functions is called the <strong>returned value</strong>.</p>
</div>
</div>
Expand Down
35 changes: 20 additions & 15 deletions slides/lesson1_slides.qmd
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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?*

. . .

Expand Down Expand Up @@ -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?

Expand Down Expand Up @@ -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

. . .
Expand All @@ -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.

. . .

Expand Down Expand Up @@ -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

Expand All @@ -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

. . .
Expand Down Expand Up @@ -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**.
:::
Expand Down

0 comments on commit 5d1dd04

Please sign in to comment.