You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"> Another way to do this is to use the `dplyr` function `arrange()`, which\n"
"> arranges the rows in a data frame according to the order of one or more\n"
"> variables from the data frame. It has similar syntax to other functions from\n"
"> the `dplyr` package. You can use `desc()` inside `arrange()` to sort in\n"
"> descending order.\n"
"> >\n"
"> >~~~\n"
"> >lifeExp_bycountry %>%\n"
"> > arrange(mean_lifeExp) %>%\n"
"> > head(1)\n"
"> >~~~\n"
"> >{: .language-r}\n"
"> >\n"
"> >\n"
"> >\n"
"> >~~~\n"
"> ># A tibble: 1 x 2\n"
"> > country mean_lifeExp\n"
"> > <fct> <dbl>\n"
"> >1 Sierra Leone 36.8\n"
"> >~~~\n"
"> >{: .output}\n"
"> >\n"
"> >\n"
"> >\n"
"> >~~~\n"
"> >lifeExp_bycountry %>%\n"
"> > arrange(desc(mean_lifeExp)) %>%\n"
"> > head(1)\n"
"> >~~~\n"
"> >{: .language-r}\n"
"> >\n"
"> >\n"
"> >\n"
"> >~~~\n"
"> ># A tibble: 1 x 2\n"
"> > country mean_lifeExp\n"
"> > <fct> <dbl>\n"
"> >1 Iceland 76.5\n"
"> >~~~\n"
"> >{: .output}"
#:r-novice-gapminder/_episodes/13-dplyr.md:352
msgid"The function `group_by()` allows us to group by multiple variables. Let's group by `year` and `continent`."
msgstr"The function `group_by()` allows us to group by multiple variables. Let's group by `year` and `continent`."
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:356
msgid""
"~~~\n"
"gdp_bycontinents_byyear <- gapminder %>%\n"
" group_by(continent,year) %>%\n"
" summarize(mean_gdpPercap=mean(gdpPercap))\n"
"~~~"
msgstr""
"~~~\n"
"gdp_bycontinents_byyear <- gapminder %>%\n"
" group_by(continent,year) %>%\n"
" summarize(mean_gdpPercap=mean(gdpPercap))\n"
"~~~"
#:r-novice-gapminder/_episodes/13-dplyr.md:363
msgid"That is already quite powerful, but it gets even better! You're not limited to defining 1 new variable in `summarize()`."
msgstr"That is already quite powerful, but it gets even better! You're not limited to defining 1 new variable in `summarize()`."
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:366
msgid""
"~~~\n"
"gdp_pop_bycontinents_byyear <- gapminder %>%\n"
" group_by(continent,year) %>%\n"
" summarize(mean_gdpPercap=mean(gdpPercap),\n"
" sd_gdpPercap=sd(gdpPercap),\n"
" mean_pop=mean(pop),\n"
" sd_pop=sd(pop))\n"
"~~~"
msgstr""
"~~~\n"
"gdp_pop_bycontinents_byyear <- gapminder %>%\n"
" group_by(continent,year) %>%\n"
" summarize(mean_gdpPercap=mean(gdpPercap),\n"
" sd_gdpPercap=sd(gdpPercap),\n"
" mean_pop=mean(pop),\n"
" sd_pop=sd(pop))\n"
"~~~"
# header
#:r-novice-gapminder/_episodes/13-dplyr.md:376
msgid"## count() and n()"
msgstr"## count() and n()"
#:r-novice-gapminder/_episodes/13-dplyr.md:378
msgid""
"A very common operation is to count the number of observations for each\n"
"group. The `dplyr` package comes with two related functions that help with this."
msgstr""
"A very common operation is to count the number of observations for each\n"
"group. The `dplyr` package comes with two related functions that help with this."
#:r-novice-gapminder/_episodes/13-dplyr.md:381
msgid""
"For instance, if we wanted to check the number of countries included in the\n"
"dataset for the year 2002, we can use the `count()` function. It takes the name\n"
"of one or more columns that contain the groups we are interested in, and we can\n"
"optionally sort the results in descending order by adding `sort=TRUE`:"
msgstr""
"For instance, if we wanted to check the number of countries included in the\n"
"dataset for the year 2002, we can use the `count()` function. It takes the name\n"
"of one or more columns that contain the groups we are interested in, and we can\n"
"optionally sort the results in descending order by adding `sort=TRUE`:"
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:387
msgid""
"~~~\n"
"gapminder %>%\n"
" filter(year == 2002) %>%\n"
" count(continent, sort = TRUE)\n"
"~~~"
msgstr""
"~~~\n"
"gapminder %>%\n"
" filter(year == 2002) %>%\n"
" count(continent, sort = TRUE)\n"
"~~~"
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:396
msgid""
"~~~\n"
"# A tibble: 5 x 2\n"
" continent n\n"
" <fct> <int>\n"
"1 Africa 52\n"
"2 Asia 33\n"
"3 Europe 30\n"
"4 Americas 25\n"
"5 Oceania 2\n"
"~~~"
msgstr""
"~~~\n"
"# A tibble: 5 x 2\n"
" continent n\n"
" <fct> <int>\n"
"1 Africa 52\n"
"2 Asia 33\n"
"3 Europe 30\n"
"4 Americas 25\n"
"5 Oceania 2\n"
"~~~"
#:r-novice-gapminder/_episodes/13-dplyr.md:408
msgid""
"If we need to use the number of observations in calculations, the `n()` function\n"
"is useful. For instance, if we wanted to get the standard error of the life\n"
"expectency per continent:"
msgstr""
"If we need to use the number of observations in calculations, the `n()` function\n"
"is useful. For instance, if we wanted to get the standard error of the life\n"
"expectency per continent:"
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:413
msgid""
"~~~\n"
"gapminder %>%\n"
" group_by(continent) %>%\n"
" summarize(se_le = sd(lifeExp)/sqrt(n()))\n"
"~~~"
msgstr""
"~~~\n"
"gapminder %>%\n"
" group_by(continent) %>%\n"
" summarize(se_le = sd(lifeExp)/sqrt(n()))\n"
"~~~"
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:422
msgid""
"~~~\n"
"# A tibble: 5 x 2\n"
" continent se_le\n"
" <fct> <dbl>\n"
"1 Africa 0.366\n"
"2 Americas 0.540\n"
"3 Asia 0.596\n"
"4 Europe 0.286\n"
"5 Oceania 0.775\n"
"~~~"
msgstr""
"~~~\n"
"# A tibble: 5 x 2\n"
" continent se_le\n"
" <fct> <dbl>\n"
"1 Africa 0.366\n"
"2 Americas 0.540\n"
"3 Asia 0.596\n"
"4 Europe 0.286\n"
"5 Oceania 0.775\n"
"~~~"
#:r-novice-gapminder/_episodes/13-dplyr.md:434
msgid"You can also chain together several summary operations; in this case calculating the `minimum`, `maximum`, `mean` and `se` of each continent's per-country life-expectancy:"
msgstr"You can also chain together several summary operations; in this case calculating the `minimum`, `maximum`, `mean` and `se` of each continent's per-country life-expectancy:"
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:437
msgid""
"~~~\n"
"gapminder %>%\n"
" group_by(continent) %>%\n"
" summarize(\n"
" mean_le = mean(lifeExp),\n"
" min_le = min(lifeExp),\n"
" max_le = max(lifeExp),\n"
" se_le = sd(lifeExp)/sqrt(n()))\n"
"~~~"
msgstr""
"~~~\n"
"gapminder %>%\n"
" group_by(continent) %>%\n"
" summarize(\n"
" mean_le = mean(lifeExp),\n"
" min_le = min(lifeExp),\n"
" max_le = max(lifeExp),\n"
" se_le = sd(lifeExp)/sqrt(n()))\n"
"~~~"
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:450
msgid""
"~~~\n"
"# A tibble: 5 x 5\n"
" continent mean_le min_le max_le se_le\n"
" <fct> <dbl> <dbl> <dbl> <dbl>\n"
"1 Africa 48.9 23.6 76.4 0.366\n"
"2 Americas 64.7 37.6 80.7 0.540\n"
"3 Asia 60.1 28.8 82.6 0.596\n"
"4 Europe 71.9 43.6 81.8 0.286\n"
"5 Oceania 74.3 69.1 81.2 0.775\n"
"~~~"
msgstr""
"~~~\n"
"# A tibble: 5 x 5\n"
" continent mean_le min_le max_le se_le\n"
" <fct> <dbl> <dbl> <dbl> <dbl>\n"
"1 Africa 48.9 23.6 76.4 0.366\n"
"2 Americas 64.7 37.6 80.7 0.540\n"
"3 Asia 60.1 28.8 82.6 0.596\n"
"4 Europe 71.9 43.6 81.8 0.286\n"
"5 Oceania 74.3 69.1 81.2 0.775\n"
"~~~"
# header
#:r-novice-gapminder/_episodes/13-dplyr.md:462
msgid"## Using mutate()"
msgstr"## Using mutate()"
#:r-novice-gapminder/_episodes/13-dplyr.md:464
msgid"We can also create new variables prior to (or even after) summarizing information using `mutate()`."
msgstr"We can also create new variables prior to (or even after) summarizing information using `mutate()`."
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:467
msgid""
"~~~\n"
"gdp_pop_bycontinents_byyear <- gapminder %>%\n"
" mutate(gdp_billion=gdpPercap*pop/10^9) %>%\n"
" group_by(continent,year) %>%\n"
" summarize(mean_gdpPercap=mean(gdpPercap),\n"
" sd_gdpPercap=sd(gdpPercap),\n"
" mean_pop=mean(pop),\n"
" sd_pop=sd(pop),\n"
" mean_gdp_billion=mean(gdp_billion),\n"
" sd_gdp_billion=sd(gdp_billion))\n"
"~~~"
msgstr""
"~~~\n"
"gdp_pop_bycontinents_byyear <- gapminder %>%\n"
" mutate(gdp_billion=gdpPercap*pop/10^9) %>%\n"
" group_by(continent,year) %>%\n"
" summarize(mean_gdpPercap=mean(gdpPercap),\n"
" sd_gdpPercap=sd(gdpPercap),\n"
" mean_pop=mean(pop),\n"
" sd_pop=sd(pop),\n"
" mean_gdp_billion=mean(gdp_billion),\n"
" sd_gdp_billion=sd(gdp_billion))\n"
"~~~"
# header
#:r-novice-gapminder/_episodes/13-dplyr.md:480
msgid"## Connect mutate with logical filtering: ifelse"
msgstr"## Connect mutate with logical filtering: ifelse"
#:r-novice-gapminder/_episodes/13-dplyr.md:482
msgid""
"When creating new variables, we can hook this with a logical condition. A simple combination of\n"
"`mutate()` and `ifelse()` facilitates filtering right where it is needed: in the moment of creating something new.\n"
"This easy-to-read statement is a fast and powerful way of discarding certain data (even though the overall dimension\n"
"of the data frame will not change) or for updating values depending on this given condition."
msgstr""
"When creating new variables, we can hook this with a logical condition. A simple combination of\n"
"`mutate()` and `ifelse()` facilitates filtering right where it is needed: in the moment of creating something new.\n"
"This easy-to-read statement is a fast and powerful way of discarding certain data (even though the overall dimension\n"
"of the data frame will not change) or for updating values depending on this given condition."
# code block
#:r-novice-gapminder/_episodes/13-dplyr.md:488
msgid""
"~~~\n"
"## keeping all data but \"filtering\" after a certain condition\n"
"# calculate GDP only for people with a life expectation above 25\n"
Translation of section 13 on
dplyr
(lines 16940 to 18112)セクション13
dplyr
の翻訳 (16940 から 18112 まで)i18n/po/r-novice-gapminder.ja.po
Lines 16940 to 18112 in 5f1d2d1
The text was updated successfully, but these errors were encountered: