Skip to content

Commit

Permalink
after lectures
Browse files Browse the repository at this point in the history
  • Loading branch information
nxskok committed Jan 21, 2024
1 parent 82d4add commit ffb9168
Show file tree
Hide file tree
Showing 22 changed files with 486 additions and 634 deletions.
8 changes: 3 additions & 5 deletions _freeze/choosing/execute-results/html.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/graphs/execute-results/html.json

Large diffs are not rendered by default.

Binary file modified _freeze/graphs/figure-revealjs/graphs-R-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/graphs/figure-revealjs/graphs-R-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/graphs/figure-revealjs/unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/graphs/figure-revealjs/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions _freeze/logistic/execute-results/html.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/logistic/figure-revealjs/unnamed-chunk-16-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/logistic/figure-revealjs/virtusentella-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions choosing.html

Large diffs are not rendered by default.

27 changes: 4 additions & 23 deletions choosing.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ athletes %>% select(Sport)
athletes %>% select(Sport, Hg, BMI)
```

## Choosing consecAutive columns
## Choosing consecutive columns

```{r choosing-R-4}
athletes %>% select(Sex:WCC)
Expand All @@ -58,7 +58,7 @@ Other ways to select columns: those whose name:
- `matches` a "regular expression"
- `everything()` select all the columns

## Columns whose names Abegin with S
## Columns whose names begin with S

```{r choosing-R-6}
athletes %>% select(starts_with("S"))
Expand Down Expand Up @@ -229,8 +229,6 @@ contains).

Two ways:

\small

```{r choosing-R-26}
athletes %>% group_by(Sex) %>% summarize(m = mean(Ht))
```
Expand All @@ -241,12 +239,10 @@ athletes %>%
summarize(m = mean(Ht))
```

\normalsize

## Summary of data selection/arrangement "verbs" {.smaller}

| Verb | Purpose |
|:---------------|:-------------------------------------------------------|
|:-----------------|:-----------------------------------------------------|
| `select` | Choose columns |
| `slice` | Choose rows by number |
| `slice_sample` | Choose random rows |
Expand Down Expand Up @@ -277,8 +273,6 @@ sales

- Fortunately you found a list of product descriptions and prices:

\small

```{r choosing-R-29, message=FALSE}
my_url <- "http://ritsokiguess.site/datafiles/nail_desc.csv"
desc <- read_csv(my_url)
Expand All @@ -289,8 +283,6 @@ desc
the same symbol for the start and end of text, so the `"`
representing "inches" is "escaped". Hence the odd look.

\normalsize

## The lookup

- How do you "look up" the product codes to find the product
Expand Down Expand Up @@ -336,15 +328,11 @@ sales %>% left_join(desc) %>%
- Suppose the `sales` dataframe *also* had a column `qty` (which was
the quantity sold):

\small

```{r choosing-R-32}
sales %>% rename("qty"="sales") -> sales1
sales1
```

\normalsize

- The `qty` in `sales1` is the quantity sold, but the `qty` in `desc`
is the number of nails in a package. These should *not* be matched:
they are different things.
Expand All @@ -355,6 +343,7 @@ sales1
sales1 %>%
left_join(desc, join_by(product_code))
```

```{r}
sales1 %>%
left_join(desc)
Expand All @@ -367,15 +356,11 @@ sales1 %>%

- Suppose the product code in `sales` was just `code`:

\small

```{r choosing-R-34}
sales %>% rename("code" = "product_code") -> sales2
sales2
```

\normalsize

- How to match the two product codes that have different names?

## Matching on different names 2/2
Expand All @@ -399,14 +384,10 @@ sales2 %>%

## Full join here

\small

```{r choosing-R-36}
sales %>% full_join(desc)
```

\normalsize

- The missing `sales` for "masonry nail" says that it was in the
lookup table `desc`, but we didn't sell any.

Expand Down
64 changes: 31 additions & 33 deletions graphs.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion graphs.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ ggplot(athletes, aes(x = Sport, y = BMI, colour = Sex)) +

## Height and weight by gender

```{r graphs-R-11, fig.height=3.6}
```{r}
#| fig-height: 9
#| fig-width: 9
ggplot(athletes, aes(x = Ht, y = Wt, colour = Sex)) +
geom_point()
```
Expand Down
327 changes: 190 additions & 137 deletions logistic.html

Large diffs are not rendered by default.

Loading

0 comments on commit ffb9168

Please sign in to comment.