Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Icon
Empty file.
9 changes: 7 additions & 2 deletions code/r-basics.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ numbers[c(1, 3)] # access the first and last element

In R (unlike in Python for example), 1 refers to the first element of a vector (or list).



#### Matrix

We build a matrix using the `matrix()` function, and we use `[]` to access its elements.
Expand Down Expand Up @@ -428,7 +430,8 @@ Here is how the RMSE is defined:

$$
\text{RMSE} = \sqrt\frac{\sum_{i=1}^n(\hat{y}_i-y_i)^2}{n}
$$ where $\hat{y}_i$ denotes the prediction, and $y_i$ the actually observed value.
$$
where $\hat{y}_i$ denotes the prediction, and $y_i$ the actually observed value.

In base R, we would do the following.

Expand Down Expand Up @@ -478,6 +481,7 @@ x = seq(from = 1, to = 5, by = 1)
log(x)

# now take the log the pipe way (write your code underneath)
x %>% log()
```

```{r}
Expand All @@ -488,6 +492,7 @@ x = seq(from = 10, to = 5, by = -1)
mean(round(sqrt(x), digits = 2))

# the pipe way (write your code underneath)
x %>% mean(round(sqrt(x), digits = 2))
```

## A quick note on naming things
Expand Down Expand Up @@ -901,7 +906,7 @@ Compute the body mass index for `masculine` characters who are `human`.
- arrange the data frame starting with the highest body mass index

```{r}
# write your code here
# I'm practicing a commit
```

## Additional resources
Expand Down
Empty file added pixi
Empty file.