Skip to content

Commit c996554

Browse files
authored
Merge pull request #708 from jhudsl/clif-basicR-summer25
Update Basic_R.Rmd
2 parents 7520d74 + 253b510 commit c996554

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

modules/Basic_R/Basic_R.Rmd

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ opts_chunk$set(comment = "")
1313

1414
## Working in R
1515

16-
For now, we will be working in the **Console** (Pane 1 )
16+
For now, we will be working in the **Console** (Pane 1) in RStudio
1717

18-
```{r, fig.align='center', out.width="70%", echo = FALSE, fig.alt= "When RStudio is first opened you will see 3 panes"}
18+
```{r, fig.align='center', out.width="50%", echo = FALSE, fig.alt= "When RStudio is first opened you will see 3 panes"}
1919
knitr::include_graphics("../RStudio/images/three_panes.png")
2020
```
2121

22+
You can follow along with the demonstrations, then there will be more time for practice during the lab at the end of lecture
23+
2224
## R as a calculator
2325

2426
- The R console is a full calculator
@@ -156,7 +158,7 @@ name
156158

157159
## Combining objects with `c()`
158160

159-
Use `c()` to collect/combine single R objects into a <span style="color:blue">vector</span> of R objects. It is mostly used for creating vectors of numbers and character strings.
161+
Use `c()` to collect/combine single R objects into a <span style="color:blue">vector</span> of R objects. It is mostly used for creating vectors of multiple items, including numbers and character strings.
160162

161163
```{r}
162164
x <- c(1, 4, 6, 8)
@@ -358,11 +360,17 @@ y <- sample(x = seq_hun, size = 5, replace = TRUE)
358360
y
359361
```
360362

363+
## When to replace in `sample()`
364+
365+
Use `replace = FALSE` if you are doing a random sample from a larger population, or if you want to randomize the order of a population.
366+
367+
Use `replace = TRUE` if you are doing bootstrapping or any resampling procedure.
368+
361369
## Installing packages to do more!
362370

363371
Some functions and data come with R right out of the box ("base R"). We will add more functionality with <span style="color:blue">packages</span>. Think of these like "expansion packs" for R.
364372

365-
Must be done **once** for each installation of R (e.g., version 4.2 \>\> 4.3).
373+
Must be done **once** for each installation of R (e.g., version 4.4 \>\> 4.5).
366374

367375
An important package we will use is `tidyverse`. It is a mega-package great for data import, wrangling, and visualization.
368376

@@ -391,6 +399,7 @@ knitr::include_graphics("../../images/lol/install_packages.jpg")
391399
## Summary
392400

393401
- R functions as a calculator
402+
- Use quotes "" for characters
394403
- Use `<-` to save (assign) values to objects. Reassigning allows you to make changes "in place".
395404
- Use `c()` to **combine** into vectors
396405
- `length()`, `class()`, and `str()` tell you information about an object

0 commit comments

Comments
 (0)