Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation: R-gapminder Section 14 #54

Closed
rikutakei opened this issue Aug 20, 2019 · 0 comments · Fixed by #91
Closed

Translation: R-gapminder Section 14 #54

rikutakei opened this issue Aug 20, 2019 · 0 comments · Fixed by #91
Assignees

Comments

@rikutakei
Copy link
Collaborator

rikutakei commented Aug 20, 2019

Translation of section 14 on tidyr (lines 18114 to 19241)

  • Please assign yourself to the issue before you start translating, so other people knows that you are translating
  • Once you have translated, send a pull request and reference this issue

セクション14 tidyr の翻訳 (18114 から 19241 まで)

  • あなたが翻訳し始めたと分かるように、翻訳を始める前にこのイシューを自分に割り振って(assign)して下さい。
  • 翻訳が終わったら、プルリクエストを開いて、このイシューを参照・リンクして下さい。

i18n/po/r-novice-gapminder.ja.po

Lines 18114 to 19241 in 5f1d2d1

# Front Matter
#: r-novice-gapminder/_episodes/14-tidyr.md:1
msgid ""
"---\n"
"# Please do not edit this file directly; it is auto generated.\n"
"# Instead, please edit 14-tidyr.md in _episodes_rmd/\n"
"title: Dataframe Manipulation with tidyr\n"
"teaching: 30\n"
"exercises: 15\n"
"questions:\n"
"- \"How can I change the format of dataframes?\"\n"
"objectives:\n"
"- \"To be understand the concepts of 'long' and 'wide' data formats and be able to convert between them with `tidyr`.\"\n"
"keypoints:\n"
"- \"Use the `tidyr` package to change the layout of dataframes.\"\n"
"- \"Use `gather()` to go from wide to long format.\"\n"
"- \"Use `spread()` to go from long to wide format.\"\n"
"source: Rmd\n"
"---"
msgstr ""
"---\n"
"# Please do not edit this file directly; it is auto generated.\n"
"# Instead, please edit 14-tidyr.md in _episodes_rmd/\n"
"title: Dataframe Manipulation with tidyr\n"
"teaching: 30\n"
"exercises: 15\n"
"questions:\n"
"- \"How can I change the format of dataframes?\"\n"
"objectives:\n"
"- \"To be understand the concepts of 'long' and 'wide' data formats and be able to convert between them with `tidyr`.\"\n"
"keypoints:\n"
"- \"Use the `tidyr` package to change the layout of dataframes.\"\n"
"- \"Use `gather()` to go from wide to long format.\"\n"
"- \"Use `spread()` to go from long to wide format.\"\n"
"source: Rmd\n"
"---"
#: r-novice-gapminder/_episodes/14-tidyr.md:20
msgid ""
"Researchers often want to manipulate their data from the 'wide' to the 'long'\n"
"format, or vice-versa. The 'long' format is where:"
msgstr ""
"Researchers often want to manipulate their data from the 'wide' to the 'long'\n"
"format, or vice-versa. The 'long' format is where:"
# unordered list
#: r-novice-gapminder/_episodes/14-tidyr.md:23
msgid " - each column is a variable"
msgstr " - each column is a variable"
# unordered list
#: r-novice-gapminder/_episodes/14-tidyr.md:24
msgid " - each row is an observation"
msgstr " - each row is an observation"
#: r-novice-gapminder/_episodes/14-tidyr.md:26
msgid ""
"In the 'long' format, you usually have 1 column for the observed variable and\n"
"the other columns are ID variables."
msgstr ""
"In the 'long' format, you usually have 1 column for the observed variable and\n"
"the other columns are ID variables."
#: r-novice-gapminder/_episodes/14-tidyr.md:30
msgid ""
"For the 'wide' format each row is often a site/subject/patient and you have\n"
"multiple observation variables containing the same type of data. These can be\n"
"either repeated observations over time, or observation of multiple variables (or\n"
"a mix of both). You may find data input may be simpler or some other\n"
"applications may prefer the 'wide' format. However, many of `R`'s functions have\n"
"been designed assuming you have 'long' format data. This tutorial will help you\n"
"efficiently transform your data regardless of original format."
msgstr ""
"For the 'wide' format each row is often a site/subject/patient and you have\n"
"multiple observation variables containing the same type of data. These can be\n"
"either repeated observations over time, or observation of multiple variables (or\n"
"a mix of both). You may find data input may be simpler or some other\n"
"applications may prefer the 'wide' format. However, many of `R`'s functions have\n"
"been designed assuming you have 'long' format data. This tutorial will help you\n"
"efficiently transform your data regardless of original format."
#: r-novice-gapminder/_episodes/14-tidyr.md:38
msgid "![](../fig/14-tidyr-fig1.png)"
msgstr "![](../fig/14-tidyr-fig1.png)"
#: r-novice-gapminder/_episodes/14-tidyr.md:40
msgid ""
"These data formats mainly affect readability. For humans, the wide format is\n"
"often more intuitive since we can often see more of the data on the screen due\n"
"to its shape. However, the long format is more machine readable and is closer\n"
"to the formatting of databases. The ID variables in our dataframes are similar to\n"
"the fields in a database and observed variables are like the database values."
msgstr ""
"These data formats mainly affect readability. For humans, the wide format is\n"
"often more intuitive since we can often see more of the data on the screen due\n"
"to its shape. However, the long format is more machine readable and is closer\n"
"to the formatting of databases. The ID variables in our dataframes are similar to\n"
"the fields in a database and observed variables are like the database values."
# header
#: r-novice-gapminder/_episodes/14-tidyr.md:46
msgid "## Getting started"
msgstr "## Getting started"
#: r-novice-gapminder/_episodes/14-tidyr.md:48
msgid ""
"First install the packages if you haven't already done so (you probably\n"
"installed dplyr in the previous lesson):"
msgstr ""
"First install the packages if you haven't already done so (you probably\n"
"installed dplyr in the previous lesson):"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:52
msgid ""
"~~~\n"
"#install.packages(\"tidyr\")\n"
"#install.packages(\"dplyr\")\n"
"~~~"
msgstr ""
"~~~\n"
"#install.packages(\"tidyr\")\n"
"#install.packages(\"dplyr\")\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:58
msgid "Load the packages"
msgstr "Load the packages"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:61
msgid ""
"~~~\n"
"library(\"tidyr\")\n"
"library(\"dplyr\")\n"
"~~~"
msgstr ""
"~~~\n"
"library(\"tidyr\")\n"
"library(\"dplyr\")\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:67
msgid "First, lets look at the structure of our original gapminder dataframe:"
msgstr "First, lets look at the structure of our original gapminder dataframe:"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:77
msgid ""
"~~~\n"
"'data.frame':\t1704 obs. of 6 variables:\n"
" $ country : chr \"Afghanistan\" \"Afghanistan\" \"Afghanistan\" \"Afghanistan\" ...\n"
" $ year : int 1952 1957 1962 1967 1972 1977 1982 1987 1992 1997 ...\n"
" $ pop : num 8425333 9240934 10267083 11537966 13079460 ...\n"
" $ continent: chr \"Asia\" \"Asia\" \"Asia\" \"Asia\" ...\n"
" $ lifeExp : num 28.8 30.3 32 34 36.1 ...\n"
" $ gdpPercap: num 779 821 853 836 740 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t1704 obs. of 6 variables:\n"
" $ country : chr \"Afghanistan\" \"Afghanistan\" \"Afghanistan\" \"Afghanistan\" ...\n"
" $ year : int 1952 1957 1962 1967 1972 1977 1982 1987 1992 1997 ...\n"
" $ pop : num 8425333 9240934 10267083 11537966 13079460 ...\n"
" $ continent: chr \"Asia\" \"Asia\" \"Asia\" \"Asia\" ...\n"
" $ lifeExp : num 28.8 30.3 32 34 36.1 ...\n"
" $ gdpPercap: num 779 821 853 836 740 ...\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:89
msgid ""
">\n"
"> Is gapminder a purely long, purely wide, or some intermediate format?\n"
">\n"
">\n"
"> > ## Solution to Challenge 1\n"
"> >\n"
"> > The original gapminder data.frame is in an intermediate format. It is not\n"
"> > purely long since it had multiple observation variables\n"
"> > (`pop`,`lifeExp`,`gdpPercap`)."
msgstr ""
">\n"
"> Is gapminder a purely long, purely wide, or some intermediate format?\n"
">\n"
">\n"
"> > ## Solution to Challenge 1\n"
"> >\n"
"> > The original gapminder data.frame is in an intermediate format. It is not\n"
"> > purely long since it had multiple observation variables\n"
"> > (`pop`,`lifeExp`,`gdpPercap`)."
#: r-novice-gapminder/_episodes/14-tidyr.md:102
msgid ""
"Sometimes, as with the gapminder dataset, we have multiple types of observed\n"
"data. It is somewhere in between the purely 'long' and 'wide' data formats. We\n"
"have 3 \"ID variables\" (`continent`, `country`, `year`) and 3 \"Observation\n"
"variables\" (`pop`,`lifeExp`,`gdpPercap`). I usually prefer my data in this\n"
"intermediate format in most cases despite not having ALL observations in 1\n"
"column given that all 3 observation variables have different units. There are\n"
"few operations that would need us to stretch out this dataframe any longer\n"
"(i.e. 4 ID variables and 1 Observation variable)."
msgstr ""
"Sometimes, as with the gapminder dataset, we have multiple types of observed\n"
"data. It is somewhere in between the purely 'long' and 'wide' data formats. We\n"
"have 3 \"ID variables\" (`continent`, `country`, `year`) and 3 \"Observation\n"
"variables\" (`pop`,`lifeExp`,`gdpPercap`). I usually prefer my data in this\n"
"intermediate format in most cases despite not having ALL observations in 1\n"
"column given that all 3 observation variables have different units. There are\n"
"few operations that would need us to stretch out this dataframe any longer\n"
"(i.e. 4 ID variables and 1 Observation variable)."
#: r-novice-gapminder/_episodes/14-tidyr.md:111
msgid ""
"While using many of the functions in R, which are often vector based, you\n"
"usually do not want to do mathematical operations on values with different\n"
"units. For example, using the purely long format, a single mean for all of the\n"
"values of population, life expectancy, and GDP would not be meaningful since it\n"
"would return the mean of values with 3 incompatible units. The solution is that\n"
"we first manipulate the data either by grouping (see the lesson on `dplyr`), or\n"
"we change the structure of the dataframe. **Note:** Some plotting functions in\n"
"R actually work better in the wide format data."
msgstr ""
"While using many of the functions in R, which are often vector based, you\n"
"usually do not want to do mathematical operations on values with different\n"
"units. For example, using the purely long format, a single mean for all of the\n"
"values of population, life expectancy, and GDP would not be meaningful since it\n"
"would return the mean of values with 3 incompatible units. The solution is that\n"
"we first manipulate the data either by grouping (see the lesson on `dplyr`), or\n"
"we change the structure of the dataframe. **Note:** Some plotting functions in\n"
"R actually work better in the wide format data."
# header
#: r-novice-gapminder/_episodes/14-tidyr.md:120
msgid "## From wide to long format with gather()"
msgstr "## From wide to long format with gather()"
#: r-novice-gapminder/_episodes/14-tidyr.md:122
msgid ""
"Until now, we've been using the nicely formatted original gapminder dataset, but\n"
"'real' data (i.e. our own research data) will never be so well organized. Here\n"
"let's start with the wide format version of the gapminder dataset."
msgstr ""
"Until now, we've been using the nicely formatted original gapminder dataset, but\n"
"'real' data (i.e. our own research data) will never be so well organized. Here\n"
"let's start with the wide format version of the gapminder dataset."
# blockquote, which can be cascaded
#: r-novice-gapminder/_episodes/14-tidyr.md:126
msgid "> Download the wide version of the gapminder data from [here](https://raw.githubusercontent.com/swcarpentry/r-novice-gapminder/gh-pages/_episodes_rmd/data/gapminder_wide.csv)"
msgstr "> Download the wide version of the gapminder data from [here](https://raw.githubusercontent.com/swcarpentry/r-novice-gapminder/gh-pages/_episodes_rmd/data/gapminder_wide.csv)"
#: r-novice-gapminder/_episodes/14-tidyr.md:127
msgid "and save it in your data folder."
msgstr "and save it in your data folder."
#: r-novice-gapminder/_episodes/14-tidyr.md:129
msgid ""
"We'll load the data file and look at it. Note: we don't want our continent and\n"
"country columns to be factors, so we use the stringsAsFactors argument for\n"
"`read.csv()` to disable that."
msgstr ""
"We'll load the data file and look at it. Note: we don't want our continent and\n"
"country columns to be factors, so we use the stringsAsFactors argument for\n"
"`read.csv()` to disable that."
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:134
msgid ""
"~~~\n"
"gap_wide <- read.csv(\"data/gapminder_wide.csv\", stringsAsFactors = FALSE)\n"
"str(gap_wide)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_wide <- read.csv(\"data/gapminder_wide.csv\", stringsAsFactors = FALSE)\n"
"str(gap_wide)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:142
msgid ""
"~~~\n"
"'data.frame':\t142 obs. of 38 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ gdpPercap_1952: num 2449 3521 1063 851 543 ...\n"
" $ gdpPercap_1957: num 3014 3828 960 918 617 ...\n"
" $ gdpPercap_1962: num 2551 4269 949 984 723 ...\n"
" $ gdpPercap_1967: num 3247 5523 1036 1215 795 ...\n"
" $ gdpPercap_1972: num 4183 5473 1086 2264 855 ...\n"
" $ gdpPercap_1977: num 4910 3009 1029 3215 743 ...\n"
" $ gdpPercap_1982: num 5745 2757 1278 4551 807 ...\n"
" $ gdpPercap_1987: num 5681 2430 1226 6206 912 ...\n"
" $ gdpPercap_1992: num 5023 2628 1191 7954 932 ...\n"
" $ gdpPercap_1997: num 4797 2277 1233 8647 946 ...\n"
" $ gdpPercap_2002: num 5288 2773 1373 11004 1038 ...\n"
" $ gdpPercap_2007: num 6223 4797 1441 12570 1217 ...\n"
" $ lifeExp_1952 : num 43.1 30 38.2 47.6 32 ...\n"
" $ lifeExp_1957 : num 45.7 32 40.4 49.6 34.9 ...\n"
" $ lifeExp_1962 : num 48.3 34 42.6 51.5 37.8 ...\n"
" $ lifeExp_1967 : num 51.4 36 44.9 53.3 40.7 ...\n"
" $ lifeExp_1972 : num 54.5 37.9 47 56 43.6 ...\n"
" $ lifeExp_1977 : num 58 39.5 49.2 59.3 46.1 ...\n"
" $ lifeExp_1982 : num 61.4 39.9 50.9 61.5 48.1 ...\n"
" $ lifeExp_1987 : num 65.8 39.9 52.3 63.6 49.6 ...\n"
" $ lifeExp_1992 : num 67.7 40.6 53.9 62.7 50.3 ...\n"
" $ lifeExp_1997 : num 69.2 41 54.8 52.6 50.3 ...\n"
" $ lifeExp_2002 : num 71 41 54.4 46.6 50.6 ...\n"
" $ lifeExp_2007 : num 72.3 42.7 56.7 50.7 52.3 ...\n"
" $ pop_1952 : num 9279525 4232095 1738315 442308 4469979 ...\n"
" $ pop_1957 : num 10270856 4561361 1925173 474639 4713416 ...\n"
" $ pop_1962 : num 11000948 4826015 2151895 512764 4919632 ...\n"
" $ pop_1967 : num 12760499 5247469 2427334 553541 5127935 ...\n"
" $ pop_1972 : num 14760787 5894858 2761407 619351 5433886 ...\n"
" $ pop_1977 : num 17152804 6162675 3168267 781472 5889574 ...\n"
" $ pop_1982 : num 20033753 7016384 3641603 970347 6634596 ...\n"
" $ pop_1987 : num 23254956 7874230 4243788 1151184 7586551 ...\n"
" $ pop_1992 : num 26298373 8735988 4981671 1342614 8878303 ...\n"
" $ pop_1997 : num 29072015 9875024 6066080 1536536 10352843 ...\n"
" $ pop_2002 : int 31287142 10866106 7026113 1630347 12251209 7021078 15929988 4048013 8835739 614382 ...\n"
" $ pop_2007 : int 33333216 12420476 8078314 1639131 14326203 8390505 17696293 4369038 10238807 710960 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t142 obs. of 38 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ gdpPercap_1952: num 2449 3521 1063 851 543 ...\n"
" $ gdpPercap_1957: num 3014 3828 960 918 617 ...\n"
" $ gdpPercap_1962: num 2551 4269 949 984 723 ...\n"
" $ gdpPercap_1967: num 3247 5523 1036 1215 795 ...\n"
" $ gdpPercap_1972: num 4183 5473 1086 2264 855 ...\n"
" $ gdpPercap_1977: num 4910 3009 1029 3215 743 ...\n"
" $ gdpPercap_1982: num 5745 2757 1278 4551 807 ...\n"
" $ gdpPercap_1987: num 5681 2430 1226 6206 912 ...\n"
" $ gdpPercap_1992: num 5023 2628 1191 7954 932 ...\n"
" $ gdpPercap_1997: num 4797 2277 1233 8647 946 ...\n"
" $ gdpPercap_2002: num 5288 2773 1373 11004 1038 ...\n"
" $ gdpPercap_2007: num 6223 4797 1441 12570 1217 ...\n"
" $ lifeExp_1952 : num 43.1 30 38.2 47.6 32 ...\n"
" $ lifeExp_1957 : num 45.7 32 40.4 49.6 34.9 ...\n"
" $ lifeExp_1962 : num 48.3 34 42.6 51.5 37.8 ...\n"
" $ lifeExp_1967 : num 51.4 36 44.9 53.3 40.7 ...\n"
" $ lifeExp_1972 : num 54.5 37.9 47 56 43.6 ...\n"
" $ lifeExp_1977 : num 58 39.5 49.2 59.3 46.1 ...\n"
" $ lifeExp_1982 : num 61.4 39.9 50.9 61.5 48.1 ...\n"
" $ lifeExp_1987 : num 65.8 39.9 52.3 63.6 49.6 ...\n"
" $ lifeExp_1992 : num 67.7 40.6 53.9 62.7 50.3 ...\n"
" $ lifeExp_1997 : num 69.2 41 54.8 52.6 50.3 ...\n"
" $ lifeExp_2002 : num 71 41 54.4 46.6 50.6 ...\n"
" $ lifeExp_2007 : num 72.3 42.7 56.7 50.7 52.3 ...\n"
" $ pop_1952 : num 9279525 4232095 1738315 442308 4469979 ...\n"
" $ pop_1957 : num 10270856 4561361 1925173 474639 4713416 ...\n"
" $ pop_1962 : num 11000948 4826015 2151895 512764 4919632 ...\n"
" $ pop_1967 : num 12760499 5247469 2427334 553541 5127935 ...\n"
" $ pop_1972 : num 14760787 5894858 2761407 619351 5433886 ...\n"
" $ pop_1977 : num 17152804 6162675 3168267 781472 5889574 ...\n"
" $ pop_1982 : num 20033753 7016384 3641603 970347 6634596 ...\n"
" $ pop_1987 : num 23254956 7874230 4243788 1151184 7586551 ...\n"
" $ pop_1992 : num 26298373 8735988 4981671 1342614 8878303 ...\n"
" $ pop_1997 : num 29072015 9875024 6066080 1536536 10352843 ...\n"
" $ pop_2002 : int 31287142 10866106 7026113 1630347 12251209 7021078 15929988 4048013 8835739 614382 ...\n"
" $ pop_2007 : int 33333216 12420476 8078314 1639131 14326203 8390505 17696293 4369038 10238807 710960 ...\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:185
msgid "![](../fig/14-tidyr-fig2.png)"
msgstr "![](../fig/14-tidyr-fig2.png)"
#: r-novice-gapminder/_episodes/14-tidyr.md:187
msgid ""
"The first step towards getting our nice intermediate data format is to first\n"
"convert from the wide to the long format. The `tidyr` function `gather()` will\n"
"'gather' your observation variables into a single variable."
msgstr ""
"The first step towards getting our nice intermediate data format is to first\n"
"convert from the wide to the long format. The `tidyr` function `gather()` will\n"
"'gather' your observation variables into a single variable."
#: r-novice-gapminder/_episodes/14-tidyr.md:191
msgid "![](../fig/14-tidyr-fig3.png)"
msgstr "![](../fig/14-tidyr-fig3.png)"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:194
msgid ""
"~~~\n"
"gap_long <- gap_wide %>%\n"
" gather(obstype_year, obs_values, starts_with('pop'),\n"
" starts_with('lifeExp'), starts_with('gdpPercap'))\n"
"str(gap_long)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_long <- gap_wide %>%\n"
" gather(obstype_year, obs_values, starts_with('pop'),\n"
" starts_with('lifeExp'), starts_with('gdpPercap'))\n"
"str(gap_long)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:204
msgid ""
"~~~\n"
"'data.frame':\t5112 obs. of 4 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ obstype_year: chr \"pop_1952\" \"pop_1952\" \"pop_1952\" \"pop_1952\" ...\n"
" $ obs_values : num 9279525 4232095 1738315 442308 4469979 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t5112 obs. of 4 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ obstype_year: chr \"pop_1952\" \"pop_1952\" \"pop_1952\" \"pop_1952\" ...\n"
" $ obs_values : num 9279525 4232095 1738315 442308 4469979 ...\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:213
msgid ""
"Here we have used piping syntax which is similar to what we were doing in the\n"
"previous lesson with dplyr. In fact, these are compatible and you can use a mix\n"
"of tidyr and dplyr functions by piping them together"
msgstr ""
"Here we have used piping syntax which is similar to what we were doing in the\n"
"previous lesson with dplyr. In fact, these are compatible and you can use a mix\n"
"of tidyr and dplyr functions by piping them together"
#: r-novice-gapminder/_episodes/14-tidyr.md:217
msgid ""
"Inside `gather()` we first name the new column for the new ID variable\n"
"(`obstype_year`), the name for the new amalgamated observation variable\n"
"(`obs_value`), then the names of the old observation variable. We could have\n"
"typed out all the observation variables, but as in the `select()` function (see\n"
"`dplyr` lesson), we can use the `starts_with()` argument to select all variables\n"
"that starts with the desired character string. Gather also allows the alternative\n"
"syntax of using the `-` symbol to identify which variables are not to be\n"
"gathered (i.e. ID variables)"
msgstr ""
"Inside `gather()` we first name the new column for the new ID variable\n"
"(`obstype_year`), the name for the new amalgamated observation variable\n"
"(`obs_value`), then the names of the old observation variable. We could have\n"
"typed out all the observation variables, but as in the `select()` function (see\n"
"`dplyr` lesson), we can use the `starts_with()` argument to select all variables\n"
"that starts with the desired character string. Gather also allows the alternative\n"
"syntax of using the `-` symbol to identify which variables are not to be\n"
"gathered (i.e. ID variables)"
#: r-novice-gapminder/_episodes/14-tidyr.md:226
msgid "![](../fig/14-tidyr-fig4.png)"
msgstr "![](../fig/14-tidyr-fig4.png)"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:229
msgid ""
"~~~\n"
"gap_long <- gap_wide %>% gather(obstype_year,obs_values,-continent,-country)\n"
"str(gap_long)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_long <- gap_wide %>% gather(obstype_year,obs_values,-continent,-country)\n"
"str(gap_long)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:237
msgid ""
"~~~\n"
"'data.frame':\t5112 obs. of 4 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ obstype_year: chr \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" ...\n"
" $ obs_values : num 2449 3521 1063 851 543 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t5112 obs. of 4 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ obstype_year: chr \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" ...\n"
" $ obs_values : num 2449 3521 1063 851 543 ...\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:246
msgid ""
"That may seem trivial with this particular dataframe, but sometimes you have 1\n"
"ID variable and 40 Observation variables with irregular variables names. The\n"
"flexibility is a huge time saver!"
msgstr ""
"That may seem trivial with this particular dataframe, but sometimes you have 1\n"
"ID variable and 40 Observation variables with irregular variables names. The\n"
"flexibility is a huge time saver!"
#: r-novice-gapminder/_episodes/14-tidyr.md:251
msgid ""
"Now `obstype_year` actually contains 2 pieces of information, the observation\n"
"type (`pop`,`lifeExp`, or `gdpPercap`) and the `year`. We can use the\n"
"`separate()` function to split the character strings into multiple variables"
msgstr ""
"Now `obstype_year` actually contains 2 pieces of information, the observation\n"
"type (`pop`,`lifeExp`, or `gdpPercap`) and the `year`. We can use the\n"
"`separate()` function to split the character strings into multiple variables"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:256
msgid ""
"~~~\n"
"gap_long <- gap_long %>% separate(obstype_year,into=c('obs_type','year'),sep=\"_\")\n"
"gap_long$year <- as.integer(gap_long$year)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_long <- gap_long %>% separate(obstype_year,into=c('obs_type','year'),sep=\"_\")\n"
"gap_long$year <- as.integer(gap_long$year)\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:264
msgid ""
">\n"
"> Using `gap_long`, calculate the mean life expectancy, population, and gdpPercap for each continent.\n"
">**Hint:** use the `group_by()` and `summarize()` functions we learned in the `dplyr` lesson\n"
">\n"
"> > ## Solution to Challenge 2\n"
"> >\n"
"> >~~~\n"
"> >gap_long %>% group_by(continent,obs_type) %>%\n"
"> > summarize(means=mean(obs_values))\n"
"> >~~~\n"
"> >{: .language-r}\n"
"> >\n"
"> >\n"
"> >\n"
"> >~~~\n"
"> ># A tibble: 15 x 3\n"
"> ># Groups: continent [?]\n"
"> > continent obs_type means\n"
"> > <chr> <chr> <dbl>\n"
"> > 1 Africa gdpPercap 2194. \n"
"> > 2 Africa lifeExp 48.9\n"
"> > 3 Africa pop 9916003. \n"
"> > 4 Americas gdpPercap 7136. \n"
"> > 5 Americas lifeExp 64.7\n"
"> > 6 Americas pop 24504795. \n"
"> > 7 Asia gdpPercap 7902. \n"
"> > 8 Asia lifeExp 60.1\n"
"> > 9 Asia pop 77038722. \n"
"> >10 Europe gdpPercap 14469. \n"
"> >11 Europe lifeExp 71.9\n"
"> >12 Europe pop 17169765. \n"
"> >13 Oceania gdpPercap 18622. \n"
"> >14 Oceania lifeExp 74.3\n"
"> >15 Oceania pop 8874672. \n"
"> >~~~\n"
"> >{: .output}"
msgstr ""
">\n"
"> Using `gap_long`, calculate the mean life expectancy, population, and gdpPercap for each continent.\n"
">**Hint:** use the `group_by()` and `summarize()` functions we learned in the `dplyr` lesson\n"
">\n"
"> > ## Solution to Challenge 2\n"
"> >\n"
"> >~~~\n"
"> >gap_long %>% group_by(continent,obs_type) %>%\n"
"> > summarize(means=mean(obs_values))\n"
"> >~~~\n"
"> >{: .language-r}\n"
"> >\n"
"> >\n"
"> >\n"
"> >~~~\n"
"> ># A tibble: 15 x 3\n"
"> ># Groups: continent [?]\n"
"> > continent obs_type means\n"
"> > <chr> <chr> <dbl>\n"
"> > 1 Africa gdpPercap 2194. \n"
"> > 2 Africa lifeExp 48.9\n"
"> > 3 Africa pop 9916003. \n"
"> > 4 Americas gdpPercap 7136. \n"
"> > 5 Americas lifeExp 64.7\n"
"> > 6 Americas pop 24504795. \n"
"> > 7 Asia gdpPercap 7902. \n"
"> > 8 Asia lifeExp 60.1\n"
"> > 9 Asia pop 77038722. \n"
"> >10 Europe gdpPercap 14469. \n"
"> >11 Europe lifeExp 71.9\n"
"> >12 Europe pop 17169765. \n"
"> >13 Oceania gdpPercap 18622. \n"
"> >14 Oceania lifeExp 74.3\n"
"> >15 Oceania pop 8874672. \n"
"> >~~~\n"
"> >{: .output}"
# header
#: r-novice-gapminder/_episodes/14-tidyr.md:303
msgid "## From long to intermediate format with spread()"
msgstr "## From long to intermediate format with spread()"
#: r-novice-gapminder/_episodes/14-tidyr.md:305
msgid ""
"It is always good to check work. So, let's use the opposite of `gather()` to\n"
"spread our observation variables back out with the aptly named `spread()`. We\n"
"can then spread our `gap_long()` to the original intermediate format or the\n"
"widest format. Let's start with the intermediate format."
msgstr ""
"It is always good to check work. So, let's use the opposite of `gather()` to\n"
"spread our observation variables back out with the aptly named `spread()`. We\n"
"can then spread our `gap_long()` to the original intermediate format or the\n"
"widest format. Let's start with the intermediate format."
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:311
msgid ""
"~~~\n"
"gap_normal <- gap_long %>% spread(obs_type,obs_values)\n"
"dim(gap_normal)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_normal <- gap_long %>% spread(obs_type,obs_values)\n"
"dim(gap_normal)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:340
msgid ""
"~~~\n"
"names(gap_normal)\n"
"~~~"
msgstr ""
"~~~\n"
"names(gap_normal)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:347
msgid ""
"~~~\n"
"[1] \"continent\" \"country\" \"year\" \"gdpPercap\" \"lifeExp\" \"pop\" \n"
"~~~"
msgstr ""
"~~~\n"
"[1] \"continent\" \"country\" \"year\" \"gdpPercap\" \"lifeExp\" \"pop\" \n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:354
msgid ""
"~~~\n"
"names(gapminder)\n"
"~~~"
msgstr ""
"~~~\n"
"names(gapminder)\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:366
msgid ""
"Now we've got an intermediate dataframe `gap_normal` with the same dimensions as\n"
"the original `gapminder`, but the order of the variables is different. Let's fix\n"
"that before checking if they are `all.equal()`."
msgstr ""
"Now we've got an intermediate dataframe `gap_normal` with the same dimensions as\n"
"the original `gapminder`, but the order of the variables is different. Let's fix\n"
"that before checking if they are `all.equal()`."
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:371
msgid ""
"~~~\n"
"gap_normal <- gap_normal[,names(gapminder)]\n"
"all.equal(gap_normal,gapminder)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_normal <- gap_normal[,names(gapminder)]\n"
"all.equal(gap_normal,gapminder)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:379
msgid ""
"~~~\n"
"[1] \"Component \\\"country\\\": 1704 string mismatches\" \n"
"[2] \"Component \\\"pop\\\": Mean relative difference: 1.634504\" \n"
"[3] \"Component \\\"continent\\\": 1212 string mismatches\" \n"
"[4] \"Component \\\"lifeExp\\\": Mean relative difference: 0.203822\" \n"
"[5] \"Component \\\"gdpPercap\\\": Mean relative difference: 1.162302\"\n"
"~~~"
msgstr ""
"~~~\n"
"[1] \"Component \\\"country\\\": 1704 string mismatches\" \n"
"[2] \"Component \\\"pop\\\": Mean relative difference: 1.634504\" \n"
"[3] \"Component \\\"continent\\\": 1212 string mismatches\" \n"
"[4] \"Component \\\"lifeExp\\\": Mean relative difference: 0.203822\" \n"
"[5] \"Component \\\"gdpPercap\\\": Mean relative difference: 1.162302\"\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:390
msgid ""
"~~~\n"
"head(gap_normal)\n"
"~~~"
msgstr ""
"~~~\n"
"head(gap_normal)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:397
msgid ""
"~~~\n"
" country year pop continent lifeExp gdpPercap\n"
"1 Algeria 1952 9279525 Africa 43.077 2449.008\n"
"2 Algeria 1957 10270856 Africa 45.685 3013.976\n"
"3 Algeria 1962 11000948 Africa 48.303 2550.817\n"
"4 Algeria 1967 12760499 Africa 51.407 3246.992\n"
"5 Algeria 1972 14760787 Africa 54.518 4182.664\n"
"6 Algeria 1977 17152804 Africa 58.014 4910.417\n"
"~~~"
msgstr ""
"~~~\n"
" country year pop continent lifeExp gdpPercap\n"
"1 Algeria 1952 9279525 Africa 43.077 2449.008\n"
"2 Algeria 1957 10270856 Africa 45.685 3013.976\n"
"3 Algeria 1962 11000948 Africa 48.303 2550.817\n"
"4 Algeria 1967 12760499 Africa 51.407 3246.992\n"
"5 Algeria 1972 14760787 Africa 54.518 4182.664\n"
"6 Algeria 1977 17152804 Africa 58.014 4910.417\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:428
msgid ""
"We're almost there, the original was sorted by `country`, `continent`, then\n"
"`year`."
msgstr ""
"We're almost there, the original was sorted by `country`, `continent`, then\n"
"`year`."
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:432
msgid ""
"~~~\n"
"gap_normal <- gap_normal %>% arrange(country,continent,year)\n"
"all.equal(gap_normal,gapminder)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_normal <- gap_normal %>% arrange(country,continent,year)\n"
"all.equal(gap_normal,gapminder)\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:445
msgid ""
"That's great! We've gone from the longest format back to the intermediate and we\n"
"didn't introduce any errors in our code."
msgstr ""
"That's great! We've gone from the longest format back to the intermediate and we\n"
"didn't introduce any errors in our code."
#: r-novice-gapminder/_episodes/14-tidyr.md:448
msgid ""
"Now lets convert the long all the way back to the wide. In the wide format, we\n"
"will keep country and continent as ID variables and spread the observations\n"
"across the 3 metrics (`pop`,`lifeExp`,`gdpPercap`) and time (`year`). First we\n"
"need to create appropriate labels for all our new variables (time*metric\n"
"combinations) and we also need to unify our ID variables to simplify the process\n"
"of defining `gap_wide`"
msgstr ""
"Now lets convert the long all the way back to the wide. In the wide format, we\n"
"will keep country and continent as ID variables and spread the observations\n"
"across the 3 metrics (`pop`,`lifeExp`,`gdpPercap`) and time (`year`). First we\n"
"need to create appropriate labels for all our new variables (time*metric\n"
"combinations) and we also need to unify our ID variables to simplify the process\n"
"of defining `gap_wide`"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:456
msgid ""
"~~~\n"
"gap_temp <- gap_long %>% unite(var_ID,continent,country,sep=\"_\")\n"
"str(gap_temp)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_temp <- gap_long %>% unite(var_ID,continent,country,sep=\"_\")\n"
"str(gap_temp)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:464
msgid ""
"~~~\n"
"'data.frame':\t5112 obs. of 4 variables:\n"
" $ var_ID : chr \"Africa_Algeria\" \"Africa_Angola\" \"Africa_Benin\" \"Africa_Botswana\" ...\n"
" $ obs_type : chr \"gdpPercap\" \"gdpPercap\" \"gdpPercap\" \"gdpPercap\" ...\n"
" $ year : int 1952 1952 1952 1952 1952 1952 1952 1952 1952 1952 ...\n"
" $ obs_values: num 2449 3521 1063 851 543 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t5112 obs. of 4 variables:\n"
" $ var_ID : chr \"Africa_Algeria\" \"Africa_Angola\" \"Africa_Benin\" \"Africa_Botswana\" ...\n"
" $ obs_type : chr \"gdpPercap\" \"gdpPercap\" \"gdpPercap\" \"gdpPercap\" ...\n"
" $ year : int 1952 1952 1952 1952 1952 1952 1952 1952 1952 1952 ...\n"
" $ obs_values: num 2449 3521 1063 851 543 ...\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:475
msgid ""
"~~~\n"
"gap_temp <- gap_long %>%\n"
" unite(ID_var,continent,country,sep=\"_\") %>%\n"
" unite(var_names,obs_type,year,sep=\"_\")\n"
"str(gap_temp)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_temp <- gap_long %>%\n"
" unite(ID_var,continent,country,sep=\"_\") %>%\n"
" unite(var_names,obs_type,year,sep=\"_\")\n"
"str(gap_temp)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:485
msgid ""
"~~~\n"
"'data.frame':\t5112 obs. of 3 variables:\n"
" $ ID_var : chr \"Africa_Algeria\" \"Africa_Angola\" \"Africa_Benin\" \"Africa_Botswana\" ...\n"
" $ var_names : chr \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" ...\n"
" $ obs_values: num 2449 3521 1063 851 543 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t5112 obs. of 3 variables:\n"
" $ ID_var : chr \"Africa_Algeria\" \"Africa_Angola\" \"Africa_Benin\" \"Africa_Botswana\" ...\n"
" $ var_names : chr \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" \"gdpPercap_1952\" ...\n"
" $ obs_values: num 2449 3521 1063 851 543 ...\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:493
msgid ""
"Using `unite()` we now have a single ID variable which is a combination of\n"
"`continent`,`country`,and we have defined variable names. We're now ready to\n"
"pipe in `spread()`"
msgstr ""
"Using `unite()` we now have a single ID variable which is a combination of\n"
"`continent`,`country`,and we have defined variable names. We're now ready to\n"
"pipe in `spread()`"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:498
msgid ""
"~~~\n"
"gap_wide_new <- gap_long %>%\n"
" unite(ID_var,continent,country,sep=\"_\") %>%\n"
" unite(var_names,obs_type,year,sep=\"_\") %>%\n"
" spread(var_names,obs_values)\n"
"str(gap_wide_new)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_wide_new <- gap_long %>%\n"
" unite(ID_var,continent,country,sep=\"_\") %>%\n"
" unite(var_names,obs_type,year,sep=\"_\") %>%\n"
" spread(var_names,obs_values)\n"
"str(gap_wide_new)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:509
msgid ""
"~~~\n"
"'data.frame':\t142 obs. of 37 variables:\n"
" $ ID_var : chr \"Africa_Algeria\" \"Africa_Angola\" \"Africa_Benin\" \"Africa_Botswana\" ...\n"
" $ gdpPercap_1952: num 2449 3521 1063 851 543 ...\n"
" $ gdpPercap_1957: num 3014 3828 960 918 617 ...\n"
" $ gdpPercap_1962: num 2551 4269 949 984 723 ...\n"
" $ gdpPercap_1967: num 3247 5523 1036 1215 795 ...\n"
" $ gdpPercap_1972: num 4183 5473 1086 2264 855 ...\n"
" $ gdpPercap_1977: num 4910 3009 1029 3215 743 ...\n"
" $ gdpPercap_1982: num 5745 2757 1278 4551 807 ...\n"
" $ gdpPercap_1987: num 5681 2430 1226 6206 912 ...\n"
" $ gdpPercap_1992: num 5023 2628 1191 7954 932 ...\n"
" $ gdpPercap_1997: num 4797 2277 1233 8647 946 ...\n"
" $ gdpPercap_2002: num 5288 2773 1373 11004 1038 ...\n"
" $ gdpPercap_2007: num 6223 4797 1441 12570 1217 ...\n"
" $ lifeExp_1952 : num 43.1 30 38.2 47.6 32 ...\n"
" $ lifeExp_1957 : num 45.7 32 40.4 49.6 34.9 ...\n"
" $ lifeExp_1962 : num 48.3 34 42.6 51.5 37.8 ...\n"
" $ lifeExp_1967 : num 51.4 36 44.9 53.3 40.7 ...\n"
" $ lifeExp_1972 : num 54.5 37.9 47 56 43.6 ...\n"
" $ lifeExp_1977 : num 58 39.5 49.2 59.3 46.1 ...\n"
" $ lifeExp_1982 : num 61.4 39.9 50.9 61.5 48.1 ...\n"
" $ lifeExp_1987 : num 65.8 39.9 52.3 63.6 49.6 ...\n"
" $ lifeExp_1992 : num 67.7 40.6 53.9 62.7 50.3 ...\n"
" $ lifeExp_1997 : num 69.2 41 54.8 52.6 50.3 ...\n"
" $ lifeExp_2002 : num 71 41 54.4 46.6 50.6 ...\n"
" $ lifeExp_2007 : num 72.3 42.7 56.7 50.7 52.3 ...\n"
" $ pop_1952 : num 9279525 4232095 1738315 442308 4469979 ...\n"
" $ pop_1957 : num 10270856 4561361 1925173 474639 4713416 ...\n"
" $ pop_1962 : num 11000948 4826015 2151895 512764 4919632 ...\n"
" $ pop_1967 : num 12760499 5247469 2427334 553541 5127935 ...\n"
" $ pop_1972 : num 14760787 5894858 2761407 619351 5433886 ...\n"
" $ pop_1977 : num 17152804 6162675 3168267 781472 5889574 ...\n"
" $ pop_1982 : num 20033753 7016384 3641603 970347 6634596 ...\n"
" $ pop_1987 : num 23254956 7874230 4243788 1151184 7586551 ...\n"
" $ pop_1992 : num 26298373 8735988 4981671 1342614 8878303 ...\n"
" $ pop_1997 : num 29072015 9875024 6066080 1536536 10352843 ...\n"
" $ pop_2002 : num 31287142 10866106 7026113 1630347 12251209 ...\n"
" $ pop_2007 : num 33333216 12420476 8078314 1639131 14326203 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t142 obs. of 37 variables:\n"
" $ ID_var : chr \"Africa_Algeria\" \"Africa_Angola\" \"Africa_Benin\" \"Africa_Botswana\" ...\n"
" $ gdpPercap_1952: num 2449 3521 1063 851 543 ...\n"
" $ gdpPercap_1957: num 3014 3828 960 918 617 ...\n"
" $ gdpPercap_1962: num 2551 4269 949 984 723 ...\n"
" $ gdpPercap_1967: num 3247 5523 1036 1215 795 ...\n"
" $ gdpPercap_1972: num 4183 5473 1086 2264 855 ...\n"
" $ gdpPercap_1977: num 4910 3009 1029 3215 743 ...\n"
" $ gdpPercap_1982: num 5745 2757 1278 4551 807 ...\n"
" $ gdpPercap_1987: num 5681 2430 1226 6206 912 ...\n"
" $ gdpPercap_1992: num 5023 2628 1191 7954 932 ...\n"
" $ gdpPercap_1997: num 4797 2277 1233 8647 946 ...\n"
" $ gdpPercap_2002: num 5288 2773 1373 11004 1038 ...\n"
" $ gdpPercap_2007: num 6223 4797 1441 12570 1217 ...\n"
" $ lifeExp_1952 : num 43.1 30 38.2 47.6 32 ...\n"
" $ lifeExp_1957 : num 45.7 32 40.4 49.6 34.9 ...\n"
" $ lifeExp_1962 : num 48.3 34 42.6 51.5 37.8 ...\n"
" $ lifeExp_1967 : num 51.4 36 44.9 53.3 40.7 ...\n"
" $ lifeExp_1972 : num 54.5 37.9 47 56 43.6 ...\n"
" $ lifeExp_1977 : num 58 39.5 49.2 59.3 46.1 ...\n"
" $ lifeExp_1982 : num 61.4 39.9 50.9 61.5 48.1 ...\n"
" $ lifeExp_1987 : num 65.8 39.9 52.3 63.6 49.6 ...\n"
" $ lifeExp_1992 : num 67.7 40.6 53.9 62.7 50.3 ...\n"
" $ lifeExp_1997 : num 69.2 41 54.8 52.6 50.3 ...\n"
" $ lifeExp_2002 : num 71 41 54.4 46.6 50.6 ...\n"
" $ lifeExp_2007 : num 72.3 42.7 56.7 50.7 52.3 ...\n"
" $ pop_1952 : num 9279525 4232095 1738315 442308 4469979 ...\n"
" $ pop_1957 : num 10270856 4561361 1925173 474639 4713416 ...\n"
" $ pop_1962 : num 11000948 4826015 2151895 512764 4919632 ...\n"
" $ pop_1967 : num 12760499 5247469 2427334 553541 5127935 ...\n"
" $ pop_1972 : num 14760787 5894858 2761407 619351 5433886 ...\n"
" $ pop_1977 : num 17152804 6162675 3168267 781472 5889574 ...\n"
" $ pop_1982 : num 20033753 7016384 3641603 970347 6634596 ...\n"
" $ pop_1987 : num 23254956 7874230 4243788 1151184 7586551 ...\n"
" $ pop_1992 : num 26298373 8735988 4981671 1342614 8878303 ...\n"
" $ pop_1997 : num 29072015 9875024 6066080 1536536 10352843 ...\n"
" $ pop_2002 : num 31287142 10866106 7026113 1630347 12251209 ...\n"
" $ pop_2007 : num 33333216 12420476 8078314 1639131 14326203 ...\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:552
msgid ""
">\n"
"> Take this 1 step further and create a `gap_ludicrously_wide` format data by spreading over countries, year and the 3 metrics?\n"
">**Hint** this new dataframe should only have 5 rows.\n"
">\n"
"> > ## Solution to Challenge 3\n"
"> >\n"
"> >~~~\n"
"> >gap_ludicrously_wide <- gap_long %>%\n"
"> > unite(var_names,obs_type,year,country,sep=\"_\") %>%\n"
"> > spread(var_names,obs_values)\n"
"> >~~~\n"
"> >{: .language-r}"
msgstr ""
">\n"
"> Take this 1 step further and create a `gap_ludicrously_wide` format data by spreading over countries, year and the 3 metrics?\n"
">**Hint** this new dataframe should only have 5 rows.\n"
">\n"
"> > ## Solution to Challenge 3\n"
"> >\n"
"> >~~~\n"
"> >gap_ludicrously_wide <- gap_long %>%\n"
"> > unite(var_names,obs_type,year,country,sep=\"_\") %>%\n"
"> > spread(var_names,obs_values)\n"
"> >~~~\n"
"> >{: .language-r}"
#: r-novice-gapminder/_episodes/14-tidyr.md:567
msgid ""
"Now we have a great 'wide' format dataframe, but the `ID_var` could be more\n"
"usable, let's separate it into 2 variables with `separate()`"
msgstr ""
"Now we have a great 'wide' format dataframe, but the `ID_var` could be more\n"
"usable, let's separate it into 2 variables with `separate()`"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:572
msgid ""
"~~~\n"
"gap_wide_betterID <- separate(gap_wide_new,ID_var,c(\"continent\",\"country\"),sep=\"_\")\n"
"gap_wide_betterID <- gap_long %>%\n"
" unite(ID_var, continent,country,sep=\"_\") %>%\n"
" unite(var_names, obs_type,year,sep=\"_\") %>%\n"
" spread(var_names, obs_values) %>%\n"
" separate(ID_var, c(\"continent\",\"country\"),sep=\"_\")\n"
"str(gap_wide_betterID)\n"
"~~~"
msgstr ""
"~~~\n"
"gap_wide_betterID <- separate(gap_wide_new,ID_var,c(\"continent\",\"country\"),sep=\"_\")\n"
"gap_wide_betterID <- gap_long %>%\n"
" unite(ID_var, continent,country,sep=\"_\") %>%\n"
" unite(var_names, obs_type,year,sep=\"_\") %>%\n"
" spread(var_names, obs_values) %>%\n"
" separate(ID_var, c(\"continent\",\"country\"),sep=\"_\")\n"
"str(gap_wide_betterID)\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:585
msgid ""
"~~~\n"
"'data.frame':\t142 obs. of 38 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ gdpPercap_1952: num 2449 3521 1063 851 543 ...\n"
" $ gdpPercap_1957: num 3014 3828 960 918 617 ...\n"
" $ gdpPercap_1962: num 2551 4269 949 984 723 ...\n"
" $ gdpPercap_1967: num 3247 5523 1036 1215 795 ...\n"
" $ gdpPercap_1972: num 4183 5473 1086 2264 855 ...\n"
" $ gdpPercap_1977: num 4910 3009 1029 3215 743 ...\n"
" $ gdpPercap_1982: num 5745 2757 1278 4551 807 ...\n"
" $ gdpPercap_1987: num 5681 2430 1226 6206 912 ...\n"
" $ gdpPercap_1992: num 5023 2628 1191 7954 932 ...\n"
" $ gdpPercap_1997: num 4797 2277 1233 8647 946 ...\n"
" $ gdpPercap_2002: num 5288 2773 1373 11004 1038 ...\n"
" $ gdpPercap_2007: num 6223 4797 1441 12570 1217 ...\n"
" $ lifeExp_1952 : num 43.1 30 38.2 47.6 32 ...\n"
" $ lifeExp_1957 : num 45.7 32 40.4 49.6 34.9 ...\n"
" $ lifeExp_1962 : num 48.3 34 42.6 51.5 37.8 ...\n"
" $ lifeExp_1967 : num 51.4 36 44.9 53.3 40.7 ...\n"
" $ lifeExp_1972 : num 54.5 37.9 47 56 43.6 ...\n"
" $ lifeExp_1977 : num 58 39.5 49.2 59.3 46.1 ...\n"
" $ lifeExp_1982 : num 61.4 39.9 50.9 61.5 48.1 ...\n"
" $ lifeExp_1987 : num 65.8 39.9 52.3 63.6 49.6 ...\n"
" $ lifeExp_1992 : num 67.7 40.6 53.9 62.7 50.3 ...\n"
" $ lifeExp_1997 : num 69.2 41 54.8 52.6 50.3 ...\n"
" $ lifeExp_2002 : num 71 41 54.4 46.6 50.6 ...\n"
" $ lifeExp_2007 : num 72.3 42.7 56.7 50.7 52.3 ...\n"
" $ pop_1952 : num 9279525 4232095 1738315 442308 4469979 ...\n"
" $ pop_1957 : num 10270856 4561361 1925173 474639 4713416 ...\n"
" $ pop_1962 : num 11000948 4826015 2151895 512764 4919632 ...\n"
" $ pop_1967 : num 12760499 5247469 2427334 553541 5127935 ...\n"
" $ pop_1972 : num 14760787 5894858 2761407 619351 5433886 ...\n"
" $ pop_1977 : num 17152804 6162675 3168267 781472 5889574 ...\n"
" $ pop_1982 : num 20033753 7016384 3641603 970347 6634596 ...\n"
" $ pop_1987 : num 23254956 7874230 4243788 1151184 7586551 ...\n"
" $ pop_1992 : num 26298373 8735988 4981671 1342614 8878303 ...\n"
" $ pop_1997 : num 29072015 9875024 6066080 1536536 10352843 ...\n"
" $ pop_2002 : num 31287142 10866106 7026113 1630347 12251209 ...\n"
" $ pop_2007 : num 33333216 12420476 8078314 1639131 14326203 ...\n"
"~~~"
msgstr ""
"~~~\n"
"'data.frame':\t142 obs. of 38 variables:\n"
" $ continent : chr \"Africa\" \"Africa\" \"Africa\" \"Africa\" ...\n"
" $ country : chr \"Algeria\" \"Angola\" \"Benin\" \"Botswana\" ...\n"
" $ gdpPercap_1952: num 2449 3521 1063 851 543 ...\n"
" $ gdpPercap_1957: num 3014 3828 960 918 617 ...\n"
" $ gdpPercap_1962: num 2551 4269 949 984 723 ...\n"
" $ gdpPercap_1967: num 3247 5523 1036 1215 795 ...\n"
" $ gdpPercap_1972: num 4183 5473 1086 2264 855 ...\n"
" $ gdpPercap_1977: num 4910 3009 1029 3215 743 ...\n"
" $ gdpPercap_1982: num 5745 2757 1278 4551 807 ...\n"
" $ gdpPercap_1987: num 5681 2430 1226 6206 912 ...\n"
" $ gdpPercap_1992: num 5023 2628 1191 7954 932 ...\n"
" $ gdpPercap_1997: num 4797 2277 1233 8647 946 ...\n"
" $ gdpPercap_2002: num 5288 2773 1373 11004 1038 ...\n"
" $ gdpPercap_2007: num 6223 4797 1441 12570 1217 ...\n"
" $ lifeExp_1952 : num 43.1 30 38.2 47.6 32 ...\n"
" $ lifeExp_1957 : num 45.7 32 40.4 49.6 34.9 ...\n"
" $ lifeExp_1962 : num 48.3 34 42.6 51.5 37.8 ...\n"
" $ lifeExp_1967 : num 51.4 36 44.9 53.3 40.7 ...\n"
" $ lifeExp_1972 : num 54.5 37.9 47 56 43.6 ...\n"
" $ lifeExp_1977 : num 58 39.5 49.2 59.3 46.1 ...\n"
" $ lifeExp_1982 : num 61.4 39.9 50.9 61.5 48.1 ...\n"
" $ lifeExp_1987 : num 65.8 39.9 52.3 63.6 49.6 ...\n"
" $ lifeExp_1992 : num 67.7 40.6 53.9 62.7 50.3 ...\n"
" $ lifeExp_1997 : num 69.2 41 54.8 52.6 50.3 ...\n"
" $ lifeExp_2002 : num 71 41 54.4 46.6 50.6 ...\n"
" $ lifeExp_2007 : num 72.3 42.7 56.7 50.7 52.3 ...\n"
" $ pop_1952 : num 9279525 4232095 1738315 442308 4469979 ...\n"
" $ pop_1957 : num 10270856 4561361 1925173 474639 4713416 ...\n"
" $ pop_1962 : num 11000948 4826015 2151895 512764 4919632 ...\n"
" $ pop_1967 : num 12760499 5247469 2427334 553541 5127935 ...\n"
" $ pop_1972 : num 14760787 5894858 2761407 619351 5433886 ...\n"
" $ pop_1977 : num 17152804 6162675 3168267 781472 5889574 ...\n"
" $ pop_1982 : num 20033753 7016384 3641603 970347 6634596 ...\n"
" $ pop_1987 : num 23254956 7874230 4243788 1151184 7586551 ...\n"
" $ pop_1992 : num 26298373 8735988 4981671 1342614 8878303 ...\n"
" $ pop_1997 : num 29072015 9875024 6066080 1536536 10352843 ...\n"
" $ pop_2002 : num 31287142 10866106 7026113 1630347 12251209 ...\n"
" $ pop_2007 : num 33333216 12420476 8078314 1639131 14326203 ...\n"
"~~~"
# code block
#: r-novice-gapminder/_episodes/14-tidyr.md:630
msgid ""
"~~~\n"
"all.equal(gap_wide, gap_wide_betterID)\n"
"~~~"
msgstr ""
"~~~\n"
"all.equal(gap_wide, gap_wide_betterID)\n"
"~~~"
#: r-novice-gapminder/_episodes/14-tidyr.md:642
msgid "There and back again!"
msgstr "There and back again!"
# unordered list
#: r-novice-gapminder/_episodes/14-tidyr.md:647
msgid "* [R for Data Science](http://r4ds.had.co.nz/index.html)"
msgstr "* [R for Data Science](http://r4ds.had.co.nz/index.html)"
# unordered list
#: r-novice-gapminder/_episodes/14-tidyr.md:649
msgid "* [Introduction to tidyr](https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html)"
msgstr "* [Introduction to tidyr](https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html)"

@joelnitta joelnitta changed the title Translation: Lesson 14 Translation: R-gapminder Section 14 Dec 6, 2019
@rkkmk rkkmk self-assigned this Mar 21, 2020
@rkkmk rkkmk linked a pull request Apr 26, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants