Skip to content

Commit

Permalink
Merge pull request #486 from gungorMetehan/patch-2
Browse files Browse the repository at this point in the history
Update 93-appendixC.Rmd
  • Loading branch information
ismayc authored Feb 12, 2024
2 parents 9081816 + 72d0114 commit d495759
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions 93-appendixC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Let's load all the packages needed for this chapter (this assumes you've already
* `dplyr` for data wrangling
* `tidyr` for converting data to "tidy" format
* `readr` for importing spreadsheet data into R
* As well as the more advanced `purrr`, `tibble`, `stringr`, and `forcats` packages
* As well as the more advanced `purrr`, `tibble`, `stringr`, and `forcats` packages.

If needed, read Section \@ref(packages) for information on how to install and load R packages.

Expand Down Expand Up @@ -128,7 +128,7 @@ ggplot(revenue_by_type, aes(x = type, y = total_revenue)) +
labs(x = "Movie genre", y = "Total boxoffice revenue (in millions of $)")
```

Or if you want to reorder `type` in ascending order of `total_revenue`, we use `reorder()`
Or if you want to reorder `type` in ascending order of `total_revenue`, we use `reorder()`:

```{r}
revenue_by_type <- revenue_by_type %>%
Expand Down Expand Up @@ -156,7 +156,7 @@ ggplot(revenue_by_type, aes(x = type, y = total_revenue)) +
```

For more advanced categorical variable (i.e. factor) manipulations, check out
the [`forcats` package](https://forcats.tidyverse.org/){target="_blank"}. Note: `forcats` is an anagram of `factors`
the [`forcats` package](https://forcats.tidyverse.org/){target="_blank"}. Note: `forcats` is an anagram of `factors`.


![](https://github.com/tidyverse/forcats/blob/main/man/figures/logo.png?raw=true){width=20%}
Expand Down Expand Up @@ -204,7 +204,7 @@ movies_ex %>%
slice(1:10)
```

Do the same here, but return `"not romantic comedy"` if `type` is not `"rom comedy"` and this time overwrite the original `type` variable
Do the same here, but return `"not romantic comedy"` if `type` is not `"rom comedy"` and this time overwrite the original `type` variable:

```{r}
movies_ex %>%
Expand Down Expand Up @@ -316,7 +316,7 @@ So for example, the 4 proportions corresponding to R rated movies are 0.596 + 0.

### Dealing with %, commas, and \$ {#appendix-commas}

Say you have numerical data that are recorded as percentages, have commas, or are in dollar form and hence are character strings. How do you convert these to numerical values? Using the `parse_number()` function from the `readr` package inside a `mutate()`! Shout out to [Stack Overflow](https://stackoverflow.com/a/52965808/3674500){target="_blank"}
Say you have numerical data that are recorded as percentages, have commas, or are in dollar form and hence are character strings. How do you convert these to numerical values? Using the `parse_number()` function from the `readr` package inside a `mutate()`! Shout out to [Stack Overflow](https://stackoverflow.com/a/52965808/3674500){target="_blank"}.

```{r}
library(readr)
Expand Down

0 comments on commit d495759

Please sign in to comment.