{"id":76291,"date":"2020-04-01T13:42:28","date_gmt":"2020-04-01T11:42:28","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider"},"modified":"2020-04-01T13:42:28","modified_gmt":"2020-04-01T11:42:28","slug":"r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider","status":"publish","type":"post","link":"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider","title":{"rendered":"R \u043f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0438 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u041f\u0430\u043a\u0435\u0442 <strong>tidyr<\/strong> \u0432\u043b\u0438\u0437\u0430 \u0432 \u044f\u0434\u0440\u043e\u0442\u043e \u043d\u0430 \u0435\u0434\u043d\u0430 \u043e\u0442 \u043d\u0430\u0439-\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0438\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0435\u0437\u0438\u043a\u0430 R \u2014 <strong>tidyverse<\/strong>.<br \/>\n\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u0442\u0430 \u0446\u0435\u043b \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u0435 \u0434\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u0432\u0438 \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u0432 \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u0432\u0438\u0434.<\/p>\n<p><\/p>\n<p>\u041d\u0430 \u0425\u0430\u0431\u0440 \u0432\u0435\u0447\u0435 \u0438\u043c\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/248741\/\">\u043f\u0440\u0438\u0432\u043b\u0435\u0447\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u0442\u043e<\/a><\/noindex> \u043f\u043e\u0441\u0432\u0435\u0442\u0435\u043d\u0430 \u043d\u0430 \u0442\u043e\u0437\u0438 \u043f\u0430\u043a\u0435\u0442, \u043d\u043e \u0435 \u043e\u0442 2015 \u0433\u043e\u0434\u0438\u043d\u0430. \u0418\u0441\u043a\u0430\u043c \u0434\u0430 \u0440\u0430\u0437\u043a\u0430\u0436\u0430 \u0437\u0430 \u043d\u0430\u0439-\u0430\u043a\u0442\u0443\u0430\u043b\u043d\u0438\u0442\u0435 \u043f\u0440\u043e\u043c\u0435\u043d\u0438, \u0437\u0430 \u043a\u043e\u0438\u0442\u043e \u043f\u0440\u0435\u0434\u0438 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0434\u043d\u0438 \u0441\u044a\u043e\u0431\u0449\u0438 \u0430\u0432\u0442\u043e\u0440\u044a\u0442 \u0425\u0430\u0434\u043b\u0438 \u0423\u0438\u043a\u044a\u043c.<\/p>\n<p>\n<img decoding=\"async\" alt=\"R \u043f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0438 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider\" src=\"\/wp-content\/uploads\/2020\/04\/a290263b63aaea3db70e83a1ec411415.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<blockquote><p><b>SJK<\/b>: \u0424\u0443\u043d\u043a\u0446\u0438\u0438\u0442\u0435 gather() \u0438 spread() \u0449\u0435 \u0431\u044a\u0434\u0430\u0442 \u043e\u0431\u044f\u0432\u0435\u043d\u0438 \u0437\u0430 \u043e\u0441\u0442\u0430\u0440\u0435\u043b\u0438?<\/p>\n<p><b>\u0425\u0430\u0434\u043b\u0438 \u0423\u0438\u043a\u044a\u043c<\/b>: \u0412 \u043d\u044f\u043a\u0430\u043a\u0432\u0430 \u0441\u0442\u0435\u043f\u0435\u043d. \u0429\u0435 \u0441\u043f\u0440\u0435\u043c \u0434\u0430 \u043f\u0440\u0435\u043f\u043e\u0440\u044a\u0447\u0432\u0430\u043c\u0435 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0442\u0435\u0437\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0434\u0430 \u043a\u043e\u0440\u0438\u0433\u0438\u0440\u0430\u043c\u0435 \u0433\u0440\u0435\u0448\u043a\u0438\u0442\u0435 \u0432 \u0442\u044f\u0445, \u043d\u043e \u0442\u0435 \u0449\u0435 \u043f\u0440\u043e\u0434\u044a\u043b\u0436\u0430\u0442 \u0434\u0430 \u043f\u0440\u0438\u0441\u044a\u0441\u0442\u0432\u0430\u0442 \u0432 \u043f\u0430\u043a\u0435\u0442\u0430 \u0432 \u0442\u0435\u043a\u0443\u0449\u043e\u0442\u043e \u043c\u0443 \u0441\u044a\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p><\/blockquote>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2 id=\"soderzhanie\">\u0421\u044a\u0434\u044a\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<p><\/p>\n<p><em>\u0410\u043a\u043e \u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0432\u0430\u0442\u0435 \u043e\u0442 \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438, \u043c\u043e\u0433\u0430\u0442 \u0434\u0430 \u0432\u0438 \u0431\u044a\u0434\u0430\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0438 \u043c\u043e\u0438\u0442\u0435 <noindex><a rel=\"nofollow\" href=\"https:\/\/t.me\/R4marketing\">telegram<\/a><\/noindex> \u0438 <noindex><a rel=\"nofollow\" href=\"https:\/\/www.youtube.com\/R4marketing\/?sub_confirmation=1\">youtube<\/a><\/noindex> \u043a\u0430\u043d\u0430\u043b\u0438. \u041f\u043e-\u0433\u043e\u043b\u044f\u043c\u0430\u0442\u0430 \u0447\u0430\u0441\u0442 \u043e\u0442 \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u043d\u0438\u0435\u0442\u043e \u0438\u043c \u0435 \u043f\u043e\u0441\u0432\u0435\u0442\u0435\u043d\u043e \u043d\u0430 \u0435\u0437\u0438\u043a\u0430 R.<\/em><\/p>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"#koncepciya-tidydata\">\u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f\u0442\u0430 TidyData<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#osnovnye-funkcii-vhodyaschie-v-paket-tydir\">\u041e\u0441\u043d\u043e\u0432\u043d\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438 \u0432 \u043f\u0430\u043a\u0435\u0442\u0430 tidyr<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#novaya-koncepciya-preobrazovaniya-dannyh-iz-shirokogo-formata-v-dlinnyy-i-naoborot\">\u041d\u043e\u0432\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0437\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/ustnovka-naibolee-aktualnoy-versii-tidyr-0839000\">\u0418\u043d\u0441\u0442\u0430\u043b\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u043d\u0430\u0439-\u0430\u043a\u0442\u0443\u0430\u043b\u043d\u0430\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f tidyr 0.8.3.9000<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#perehod-na-novye-funkcii\">\u041f\u0440\u0435\u0445\u043e\u0434 \u043a\u044a\u043c \u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#prostoy-primer-preobrazovaniya-dannyh-iz-shirokogo-formata-v-dlinnyy\">\u041f\u0440\u043e\u0441\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#specifikacii\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#specifikaciya-s-ispolzovaniem-neskolkih-znacheniyvalue\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043d\u0435 \u043d\u0430 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438 (.value)<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#preobrazovanie-data-freymov-iz-dlinnogo-formata-k-shirokomu\">\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u043e\u0432\u0435 \u043e\u0442 \u0434\u044a\u043b\u044a\u0433 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0448\u0438\u0440\u043e\u043a<\/a><\/noindex>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"#prosteyshiy-primer-privedeniya-tablicy-k-shirokomu-formatu\">\u041d\u0430\u0439-\u043f\u0440\u043e\u0441\u0442\u0438\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u043f\u0440\u0435\u0432\u0435\u0436\u0434\u0430\u043d\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#generaciya-imeni-stolbca-iz-neskolkih-ishodnyh-peremennyh\">\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u0438\u043c\u0435 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430 \u043e\u0442 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0438\u0437\u0445\u043e\u0434\u043d\u0438 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0438<\/a><\/noindex><\/li>\n<\/ul>\n<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#neskolko-prodvinutyh-primerov-raboty-s-novoy-koncepciey-tidyr\">\u041d\u044f\u043a\u043e\u043b\u043a\u043e \u043d\u0430\u043f\u0440\u0435\u0434\u043d\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043d\u043e\u0432\u0430\u0442\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u043d\u0430 tidyr<\/a><\/noindex>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"#privedenie-dannyh-k-akkuratnomu-vidu-na-primere-nabora-dannyh-o-perepisi-dohoda-i-arendnoy-platy-v-ssha\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u0432 \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u0432\u0438\u0434 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430 \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u0437\u0430 \u0434\u043e\u0445\u043e\u0434\u0438 \u0438 \u043d\u0430\u0435\u043c\u0438 \u0432 \u0421\u0410\u0429<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#vsemirnyy-bank\">\u0421\u0432\u0435\u0442\u043e\u0432\u043d\u0430\u0442\u0430 \u0431\u0430\u043d\u043a\u0430<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#spisok-kontaktov\">\u0421\u043f\u0438\u0441\u044a\u043a \u0441 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0438<\/a><\/noindex><\/li>\n<\/ul>\n<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/a><\/noindex><\/li>\n<\/ul>\n<p><\/p>\n<h2 id=\"koncepciya-tidydata\">\u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f\u0442\u0430 TidyData<\/h2>\n<p><\/p>\n<p>\u0426\u0435\u043b <strong>tidyr<\/strong> \u2014 \u0434\u0430 \u0432\u0438 \u043f\u043e\u043c\u043e\u0433\u043d\u0435 \u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442\u0435 \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u0432 \u0442\u0430\u043a\u0430 \u043d\u0430\u0440\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u0432\u0438\u0434. \u041f\u043e\u0434\u0440\u0435\u0434\u0435\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u0438 \u2014 \u044d\u0442\u043e \u0434\u0430\u043d\u043d\u0438, \u043a\u044a\u0434\u0435\u0442\u043e: <\/p>\n<p><\/p>\n<ul>\n<li>\u0412\u0441\u044f\u043a\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430 \u0435 \u0432 \u043a\u043e\u043b\u043e\u043d\u0430. <\/li>\n<li>\u0412\u0441\u044f\u043a\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0435 \u0440\u0435\u0434. <\/li>\n<li>\u0412\u0441\u044f\u043a\u0430 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442 \u0435 \u043a\u043b\u0435\u0442\u043a\u0430.<\/li>\n<\/ul>\n<p><\/p>\n<p>\u0421 \u0434\u0430\u043d\u043d\u0438\u0442\u0435, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438 \u0432 tidy data, \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u043d\u043e \u043f\u043e-\u043b\u0435\u0441\u043d\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e \u0435 \u0434\u0430 \u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0438 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0436\u0434\u0430\u043d\u0435 \u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0437.<\/p>\n<p><\/p>\n<h2 id=\"osnovnye-funkcii-vhodyaschie-v-paket-tidyr\">\u041e\u0441\u043d\u043e\u0432\u043d\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438 \u0432 \u043f\u0430\u043a\u0435\u0442\u0430 tidyr<\/h2>\n<p><\/p>\n<p>tidyr \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438 \u0437\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0438:<\/p>\n<p><\/p>\n<ul>\n<li><code>fill()<\/code> \u2014 \u0437\u0430\u043f\u044a\u043b\u0432\u0430\u043d\u0435 \u043d\u0430 \u043b\u0438\u043f\u0441\u0432\u0430\u0449\u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438 \u0432 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430 \u0441 \u043f\u0440\u0435\u0434\u0438\u0448\u043d\u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438;<\/li>\n<li><code>separate()<\/code> \u2014 \u0440\u0430\u0437\u0434\u0435\u043b\u044f \u0435\u0434\u043d\u043e \u043f\u043e\u043b\u0435 \u043d\u0430 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u043f\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b;<\/li>\n<li><code>unite()<\/code> \u2014 \u0438\u0437\u0432\u044a\u0440\u0448\u0432\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u043e\u0431\u0435\u0434\u0438\u043d\u044f\u0432\u0430\u043d\u0435 \u043d\u0430 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u043f\u043e\u043b\u0435\u0442\u0430 \u0432 \u0435\u0434\u043d\u043e, \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0442\u0435 <code>separate()<\/code>;<\/li>\n<li><code>pivot_longer()<\/code> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u0449\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433;<\/li>\n<li><code>pivot_wider()<\/code> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u0449\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0434\u044a\u043b\u044a\u0433 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0448\u0438\u0440\u043e\u043a. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043e\u0431\u0440\u0430\u0442\u043d\u0430 \u043d\u0430 \u0442\u0430\u0437\u0438, \u043a\u043e\u044f\u0442\u043e \u0438\u0437\u0432\u044a\u0440\u0448\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_longer()<\/code>.<\/li>\n<li><code>gather()<\/code><strong>\u043e\u0441\u0442\u0430\u0440\u044f\u043b\u0430<\/strong> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u0449\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433;<\/li>\n<li><code>spread()<\/code><strong>\u043e\u0441\u0442\u0430\u0440\u044f\u043b\u0430<\/strong> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u0449\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0434\u044a\u043b\u044a\u0433 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0448\u0438\u0440\u043e\u043a. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043e\u0431\u0440\u0430\u0442\u043d\u0430 \u043d\u0430 \u0442\u0430\u0437\u0438, \u043a\u043e\u044f\u0442\u043e \u0438\u0437\u0432\u044a\u0440\u0448\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>gather()<\/code>.<\/li>\n<\/ul>\n<p><\/p>\n<h2 id=\"novaya-koncepciya-preobrazovaniya-dannyh-iz-shirokogo-formata-v-dlinnyy-i-naoborot\">\u041d\u043e\u0432\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0437\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/h2>\n<p><\/p>\n<p>\u041f\u0440\u0435\u0434\u0438\u0448\u043d\u043e \u0437\u0430 \u043f\u043e\u0434\u043e\u0431\u0435\u043d \u0432\u0438\u0434 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u0435 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u0445\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>gather()<\/code> \u0438 <code>spread()<\/code>. \u041f\u0440\u0435\u0437 \u0433\u043e\u0434\u0438\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u044a\u0449\u0435\u0441\u0442\u0432\u0443\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0442\u0435\u0437\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0435 \u0437\u0430 \u043f\u043e\u0432\u0435\u0447\u0435\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438, \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u043d\u043e \u0430\u0432\u0442\u043e\u0440\u0430 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430, \u0438\u043c\u0435\u043d\u0430\u0442\u0430 \u043d\u0430 \u0442\u0435\u0437\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0442\u0435\u0445\u043d\u0438\u0442\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438 \u043d\u0435 \u0441\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u044a\u0447\u043d\u043e \u044f\u0441\u043d\u0438 \u0438 \u043f\u0440\u0435\u0434\u0438\u0437\u0432\u0438\u043a\u0432\u0430\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0442\u044a\u0440\u0441\u0435\u043d\u0435 \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0442\u043e\u0432\u0430, \u043a\u043e\u044f \u043e\u0442 \u0442\u0435\u0437\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430 \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0432 \u0434\u044a\u043b\u044a\u0433 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<\/p>\n<p><\/p>\n<p>\u0412 \u0442\u0430\u0437\u0438 \u0432\u0440\u044a\u0437\u043a\u0430 <strong>tidyr<\/strong> \u0431\u044f\u0445\u0430 \u0434\u043e\u0431\u0430\u0432\u0435\u043d\u0438 \u0434\u0432\u0435 \u043d\u043e\u0432\u0438 \u0432\u0430\u0436\u043d\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438 \u0437\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0430 \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u043e\u0432\u0435.<\/p>\n<p><\/p>\n<p>\u041d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>pivot_longer()<\/code> \u0438 <code>pivot_wider()<\/code> \u0431\u044f\u0445\u0430 \u0432\u0434\u044a\u0445\u043d\u043e\u0432\u0435\u043d\u0438 \u043e\u0442 \u043d\u044f\u043a\u043e\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442 \u043f\u0430\u043a\u0435\u0442\u0430 <strong>cdata<\/strong>, \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043d \u043e\u0442 \u0414\u0436\u043e\u043d \u041c\u0430\u0443\u043d\u0442 \u0438 \u041d\u0438\u043d\u0430 \u0417\u0443\u043c\u0435\u043b.<\/p>\n<p><\/p>\n<h3 id=\"ustanovka-naibolee-aktualnoy-versii-tidyr-0839000\">\u0418\u043d\u0441\u0442\u0430\u043b\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u043d\u0430\u0439-\u0430\u043a\u0442\u0443\u0430\u043b\u043d\u0430\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f tidyr 0.8.3.9000<\/h3>\n<p><\/p>\n<p>\u0417\u0430 \u0438\u043d\u0441\u0442\u0430\u043b\u0430\u0446\u0438\u044f \u043d\u0430 \u043d\u043e\u0432\u0430\u0442\u0430, \u043d\u0430\u0439-\u0430\u043a\u0442\u0443\u0430\u043b\u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 <strong>tidyr<\/strong> <em>0.8.3.9000<\/em>, \u0432 \u043a\u043e\u044f\u0442\u043e \u0441\u0430 \u043d\u0430\u043b\u0438\u0447\u043d\u0438 \u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u043d\u0438\u044f \u043a\u043e\u0434.<\/p>\n<p><\/p>\n<p><code>devtools::install_github(\"tidyverse\/tidyr\")<\/code><\/p>\n<p><\/p>\n<p>\u041a\u044a\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u043d\u0430\u043f\u0438\u0441\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u044f\u0442\u0430 \u0442\u0435\u0437\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0430 \u043d\u0430\u043b\u0438\u0447\u043d\u0438 \u0441\u0430\u043c\u043e \u0432 dev \u0432\u0435\u0440\u0441\u0438\u044f\u0442\u0430 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u0432 GitHub.<\/p>\n<p><\/p>\n<h3 id=\"perehod-na-novye-funkcii\">\u041f\u0440\u0435\u0445\u043e\u0434 \u043a\u044a\u043c \u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h3>\n<p><\/p>\n<p>\u041d\u0430\u0438\u0441\u0442\u0438\u043d\u0430 \u043d\u0435 \u0435 \u0442\u0440\u0443\u0434\u043d\u043e \u0434\u0430 \u0441\u0435 \u043f\u0440\u0435\u043c\u0438\u043d\u0430\u0442 \u0441\u0442\u0430\u0440\u0438\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0435 \u043a\u044a\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0437\u0430 \u043f\u043e-\u0434\u043e\u0431\u0440\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043d\u0435, \u0449\u0435 \u0432\u0437\u0435\u043c\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0430 \u0441\u0442\u0430\u0440\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0449\u0435 \u043f\u043e\u043a\u0430\u0436\u0430 \u043a\u0430\u043a \u0442\u0435\u0437\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0435 \u0438\u0437\u043f\u044a\u043b\u043d\u044f\u0432\u0430\u0442 \u0441 \u043d\u043e\u0432\u0438\u0442\u0435 <code>pivot_*()<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p><\/p>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u043a\u043e\u0434 \u043e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 gather<\/b><\/p>\n<pre><code class=\"plaintext\"># example\nlibrary(dplyr)\nstocks &lt;- data.frame(\n  time = as.Date('2009-01-01') + 0:9,\n  X = rnorm(10, 0, 1),\n  Y = rnorm(10, 0, 2),\n  Z = rnorm(10, 0, 4)\n)\n\n# old\nstocks_gather &lt;- stocks %&gt;% gather(key   = stock, \n                                   value = price, \n                                   -time)\n\n# new\nstocks_long   &lt;- stocks %&gt;% pivot_longer(cols      = -time, \n                                       names_to  = &quot;stock&quot;, \n                                       values_to = &quot;price&quot;)\n<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043e\u0442 \u0434\u044a\u043b\u044a\u0433 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0448\u0438\u0440\u043e\u043a.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u043a\u043e\u0434 \u043e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 spread<\/b><\/p>\n<pre><code class=\"plaintext\"># old\nstocks_spread &lt;- stocks_gather %&gt;% spread(key = stock, \n                                          value = price) \n\n# new \nstock_wide    &lt;- stocks_long %&gt;% pivot_wider(names_from  = &quot;stock&quot;,\n                                            values_from = &quot;price&quot;)\n<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u044a\u0439 \u043a\u0430\u0442\u043e \u0432 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0435\u043d\u0438\u0442\u0435 \u043f\u043e-\u0433\u043e\u0440\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 <code>pivot_longer()<\/code> \u0438 <code>pivot_wider()<\/code>, \u0432 \u0438\u0437\u0445\u043e\u0434\u043d\u0430\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <em>stocks<\/em> \u043d\u044f\u043c\u0430 \u043a\u043e\u043b\u043e\u043d\u0438, \u0438\u0437\u0431\u0440\u043e\u0435\u043d\u0438 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438\u0442\u0435 <em>names_to<\/em> \u0438 <em>values_to<\/em> \u0442\u0435\u0445\u043d\u0438\u0442\u0435 \u0438\u043c\u0435\u043d\u0430 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0441\u0435 \u043f\u043e\u0441\u043e\u0447\u0432\u0430\u0442 \u0432 \u043a\u0430\u0432\u0438\u0447\u043a\u0438.<\/p>\n<p><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u0442\u0430 \u043d\u0430 \u043a\u043e\u044f\u0442\u043e \u043d\u0430\u0439-\u043b\u0435\u0441\u043d\u043e \u0449\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u043a\u0430\u043a \u0434\u0430 \u043f\u0440\u0435\u043c\u0438\u043d\u0435\u0442\u0435 \u043a\u044a\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043d\u043e\u0432\u0430\u0442\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f <strong>tidyr<\/strong>.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"R \u043f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0438 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider\" src=\"\/wp-content\/uploads\/2020\/04\/fe598b5cd152088a2f1b23b846d212e9.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h2 id=\"primechanie-ot-avtora\">\u0417\u0430\u0431\u0435\u043b\u0435\u0436\u043a\u0430 \u043e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430<\/h2>\n<p><\/p>\n<blockquote><p>\u0426\u0435\u043b\u0438\u044f\u0442 \u0441\u043b\u0435\u0434\u0432\u0430\u0449 \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0432\u0430 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u0435\u043d, \u0431\u0438\u0445 \u043a\u0430\u0437\u0430\u043b, \u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d \u043f\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/tidyr.tidyverse.org\/dev\/articles\/pivot.html\">\u0432\u0438\u043d\u0435\u0442\u043a\u0438<\/a><\/noindex> \u043e\u0442 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u043d\u0438\u044f \u0441\u0430\u0439\u0442 \u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0442\u0430 tidyverse.<\/p><\/blockquote>\n<p><\/p>\n<h2 id=\"prostoy-primer-preobrazovaniya-dannyh-iz-shirokogo-formata-v-dlinnyy\">\u041f\u0440\u043e\u0441\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433<\/h2>\n<p><\/p>\n<p><code>pivot_longer ()<\/code> \u2014 \u043f\u0440\u0430\u0432\u0438 \u043d\u0430\u0431\u043e\u0440\u0438\u0442\u0435 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u043f\u043e-\u0434\u044a\u043b\u0433\u0438, \u043d\u0430\u043c\u0430\u043b\u044f\u0432\u0430\u0439\u043a\u0438 \u0431\u0440\u043e\u044f \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0430\u0432\u0430\u0439\u043a\u0438 \u0431\u0440\u043e\u044f \u043d\u0430 \u0440\u0435\u0434\u043e\u0432\u0435\u0442\u0435.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"R \u043f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0438 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider\" src=\"\/wp-content\/uploads\/2020\/04\/fc88b99f2fecdcdaa6179d2e7d29e59d.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>\u0417\u0430 \u0438\u0437\u043f\u044a\u043b\u043d\u0435\u043d\u0438\u0435\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0438\u0442\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0435\u043d\u0438 \u0432 \u0441\u0442\u0430\u0442\u0438\u044f\u0442\u0430, \u043f\u044a\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u043d\u043e \u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0430 \u0441\u0435 \u0441\u0432\u044a\u0440\u0436\u0430\u0442 \u043d\u0443\u0436\u043d\u0438\u0442\u0435 \u043f\u0430\u043a\u0435\u0442\u0438:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">library(tidyr)\nlibrary(dplyr)\nlibrary(readr)<\/code><\/pre>\n<p><\/p>\n<p>\u0414\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0435 \u0438\u043c\u0430\u043c\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0440\u0435\u0437\u0443\u043b\u0442\u0430\u0442\u0438\u0442\u0435 \u043e\u0442 \u0430\u043d\u043a\u0435\u0442\u0430, \u0432 \u043a\u043e\u044f\u0442\u043e (\u0441\u0440\u0435\u0434 \u0434\u0440\u0443\u0433\u043e\u0442\u043e) \u043f\u043e\u043f\u0438\u0442\u0430\u043b\u0438 \u0445\u043e\u0440\u0430\u0442\u0430 \u0437\u0430 \u0442\u044f\u0445\u043d\u0430\u0442\u0430 \u0440\u0435\u043b\u0438\u0433\u0438\u044f \u0438 \u0433\u043e\u0434\u0438\u0448\u0435\u043d \u0434\u043e\u0445\u043e\u0434:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 18 x 11\n#&gt;    religion `&lt;$10k` `$10-20k` `$20-30k` `$30-40k` `$40-50k` `$50-75k`\n#&gt;    &lt;chr&gt;      &lt;dbl&gt;     &lt;dbl&gt;     &lt;dbl&gt;     &lt;dbl&gt;     &lt;dbl&gt;     &lt;dbl&gt;\n#&gt;  1 Agnostic      27        34        60        81        76       137\n#&gt;  2 Atheist       12        27        37        52        35        70\n#&gt;  3 Buddhist      27        21        30        34        33        58\n#&gt;  4 Catholic     418       617       732       670       638      1116\n#&gt;  5 Don\u2019t k\u2026      15        14        15        11        10        35\n#&gt;  6 Evangel\u2026     575       869      1064       982       881      1486\n#&gt;  7 Hindu          1         9         7         9        11        34\n#&gt;  8 Histori\u2026     228       244       236       238       197       223\n#&gt;  9 Jehovah\u2026      20        27        24        24        21        30\n#&gt; 10 Jewish        19        19        25        25        30        95\n#&gt; # \u2026 with 8 more rows, and 4 more variables: `$75-100k` &lt;dbl&gt;,\n#&gt; #   `$100-150k` &lt;dbl&gt;, `&gt;150k` &lt;dbl&gt;, `Don't know\/refused` &lt;dbl&gt;<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430\u0442\u0430 \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0434\u0430\u043d\u043d\u0438 \u0437\u0430 \u0440\u0435\u043b\u0438\u0433\u0438\u044f\u0442\u0430 \u043d\u0430 \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442\u0438\u0442\u0435 \u0432 \u0440\u0435\u0434\u043e\u0432\u0435\u0442\u0435, \u0430 \u043d\u0438\u0432\u043e\u0442\u043e \u043d\u0430 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u0435 \u0435 \u0440\u0430\u0437\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0430\u0442\u0430 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435. \u0411\u0440\u043e\u044f\u0442 \u043d\u0430 \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442\u0438\u0442\u0435 \u0432 \u0432\u0441\u044f\u043a\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f \u0435 \u0441\u044a\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438\u0442\u0435 \u043d\u0430 \u043a\u043b\u0435\u0442\u043a\u0438\u0442\u0435, \u043d\u0430 \u043f\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435\u0442\u043e \u043d\u0430 \u0440\u0435\u043b\u0438\u0433\u0438\u044f \u0438 \u043d\u0438\u0432\u043e \u043d\u0430 \u0434\u043e\u0445\u043e\u0434. \u0417\u0430 \u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0442\u0430 \u0432 \u0430\u043a\u0443\u0440\u0430\u0442\u0435\u043d, \u043f\u0440\u0430\u0432\u0438\u043b\u0435\u043d \u0444\u043e\u0440\u043c\u0430\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u044a\u0447\u043d\u043e \u0435 \u0434\u0430 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u0442\u0435 <code>pivot_longer()<\/code>:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">pew %&gt;% \n  pivot_longer(cols = -religion, names_to = \"income\", values_to = \"count\")<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">pew %&gt;% \n  pivot_longer(cols = -religion, names_to = \"income\", values_to = \"count\")\n#&gt; # A tibble: 180 x 3\n#&gt;    religion income             count\n#&gt;                      \n#&gt;  1 Agnostic   2 Agnostic 10-20k               34\n#&gt;  3 Agnostic 20-30k               60\n#&gt;  4 Agnostic 30-40k               81\n#&gt;  5 Agnostic 40-50k               76\n#&gt;  6 Agnostic 50-75k              137\n#&gt;  7 Agnostic 75-100k             122\n#&gt;  8 Agnostic 100-150k            109\n#&gt;  9 Agnostic &gt;150k                 84\n#&gt; 10 Agnostic Don't know\/refused    96\n#&gt; # \u2026 with 170 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438\u0442\u0435 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_longer()<\/code><\/p>\n<p><\/p>\n<ul>\n<li>\u041f\u044a\u0440\u0432\u0438\u044f\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <em>cols<\/em>, \u043e\u043f\u0438\u0441\u0432\u0430 \u043a\u043e\u0438 \u043a\u043e\u043b\u043e\u043d\u0438 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0431\u044a\u0434\u0430\u0442 \u043e\u0431\u0435\u0434\u0438\u043d\u0435\u043d\u0438. \u0412 \u0442\u043e\u0437\u0438 \u0441\u043b\u0443\u0447\u0430\u0439 \u0432\u0441\u0438\u0447\u043a\u0438 \u043a\u043e\u043b\u043e\u043d\u0438 \u0441 \u0438\u0437\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <em>time<\/em>.<\/li>\n<li>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <em>names_to<\/em> \u0434\u0430\u0432\u0430 \u0438\u043c\u0435 \u043d\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430\u0442\u0430, \u043a\u043e\u044f\u0442\u043e \u0449\u0435 \u0431\u044a\u0434\u0435 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043d\u0430 \u043e\u0442 \u0438\u043c\u0435\u043d\u0430\u0442\u0430 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435, \u043a\u043e\u0438\u0442\u043e \u043e\u0431\u0435\u0434\u0438\u043d\u044f\u0432\u0430\u043c\u0435.<\/li>\n<li><em>values_to<\/em> \u0434\u0430\u0432\u0430 \u0438\u043c\u0435 \u043d\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430\u0442\u0430, \u043a\u043e\u044f\u0442\u043e \u0449\u0435 \u0431\u044a\u0434\u0435 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043d\u0430 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438\u0442\u0435, \u0441\u044a\u0445\u0440\u0430\u043d\u044f\u0432\u0430\u043d\u0438 \u0432 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438\u0442\u0435 \u043d\u0430 \u043a\u043b\u0435\u0442\u043a\u0438\u0442\u0435 \u043d\u0430 \u043e\u0431\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0442\u0435 \u043a\u043e\u043b\u043e\u043d\u0438.<\/li>\n<\/ul>\n<p><\/p>\n<h2 id=\"specifikacii\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/h2>\n<p><\/p>\n<p>\u0422\u043e\u0432\u0430 \u0435 \u043d\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043d\u043e\u0441\u0442 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 <strong>tidyr<\/strong>, \u043a\u043e\u044f\u0442\u043e \u043f\u0440\u0435\u0434\u0438 \u0431\u0435\u0448\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u044a\u043f\u043d\u0430 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043e\u0441\u0442\u0430\u0440\u0435\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p><\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0442\u0430 \u0435 \u0444\u0440\u0435\u0439\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u0438, \u0432 \u043a\u043e\u0439\u0442\u043e \u0432\u0441\u0435\u043a\u0438 \u0440\u0435\u0434 \u0441\u044a\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0430 \u043d\u0430 \u0435\u0434\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430 \u0432 \u043d\u043e\u0432\u0438\u044f \u0438\u0437\u0445\u043e\u0434\u0435\u043d \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c \u0438 \u0434\u0432\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u043d\u0438 \u043a\u043e\u043b\u043e\u043d\u0438, \u043a\u043e\u0438\u0442\u043e \u0437\u0430\u043f\u043e\u0447\u0432\u0430\u0442 \u0441: <\/p>\n<p><\/p>\n<ul>\n<li><em>.\u0438\u043c\u0435<\/em> \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043d\u043e\u0442\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430. <\/li>\n<li><em>.value<\/em> \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0438\u043c\u0435\u0442\u043e \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430, \u0432 \u043a\u043e\u044f\u0442\u043e \u0449\u0435 \u0432\u043b\u0438\u0437\u0430\u0442 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438\u0442\u0435 \u043d\u0430 \u043a\u043b\u0435\u0442\u043a\u0438\u0442\u0435. <\/li>\n<\/ul>\n<p><\/p>\n<p>\u041e\u0441\u0442\u0430\u043d\u0430\u043b\u0438\u0442\u0435 \u043a\u043e\u043b\u043e\u043d\u0438 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0442\u0430 \u043e\u0442\u0440\u0430\u0437\u044f\u0432\u0430\u0442 \u043a\u0430\u043a \u0432 \u043d\u043e\u0432\u0430\u0442\u0430 \u043a\u043e\u043b\u043e\u043d\u0430 \u0449\u0435 \u0441\u0435 \u043f\u043e\u043a\u0430\u0437\u0432\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u0442\u043e \u043d\u0430 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0438\u0440\u0430\u043d\u0438\u0442\u0435 \u043a\u043e\u043b\u043e\u043d\u0438 \u043e\u0442 <em>.\u0438\u043c\u0435<\/em>.<\/p>\n<p><\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0442\u0430 \u043e\u043f\u0438\u0441\u0432\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u0438\u0442\u0435, \u0441\u044a\u0445\u0440\u0430\u043d\u044f\u0432\u0430\u043d\u0438 \u0432 \u0438\u043c\u0435\u0442\u043e \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430, \u0441 \u0435\u0434\u0438\u043d \u0440\u0435\u0434 \u0437\u0430 \u0432\u0441\u044f\u043a\u0430 \u043a\u043e\u043b\u043e\u043d\u0430 \u0438 \u0435\u0434\u0438\u043d \u043a\u043e\u043b\u043e\u043d \u0437\u0430 \u0432\u0441\u044f\u043a\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430, \u043e\u0431\u0435\u0434\u0438\u043d\u0435\u043d\u0430 \u0441 \u0438\u043c\u0435\u0442\u043e \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430; \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0441\u0435\u0433\u0430 \u0442\u0430\u043a\u043e\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u0433\u043b\u0435\u0436\u0434\u0430 \u043e\u0431\u044a\u0440\u043a\u0430\u043d\u043e, \u043d\u043e \u0441\u043b\u0435\u0434 \u0440\u0430\u0437\u0433\u043b\u0435\u0436\u0434\u0430\u043d\u0435 \u043d\u0430 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0432\u0441\u0438\u0447\u043a\u043e \u0449\u0435 \u0441\u0442\u0430\u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u043d\u043e \u043f\u043e-\u044f\u0441\u043d\u043e.<\/p>\n<p><\/p>\n<p>\u0421\u043c\u0438\u0441\u044a\u043b\u044a\u0442 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0442\u0430 \u0435, \u0447\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430 \u0438\u0437\u0432\u043b\u0438\u0447\u0430\u0442\u0435, \u043f\u0440\u043e\u043c\u0435\u043d\u044f\u0442\u0435 \u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u0435 \u043d\u043e\u0432\u0438 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u0438 \u043d\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c.<\/p>\n<p><\/p>\n<p>\u0417\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u044a\u0441 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\u0442\u0435 \u043f\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0442\u0430 \u043e\u0442 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0434\u044a\u043b\u044a\u0433 \u0441\u043b\u0443\u0436\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_longer_spec()<\/code>.<\/p>\n<p><\/p>\n<p>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0438 \u0442\u0430\u0437\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f? \u0422\u044f \u0432\u0437\u0435\u043c\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u0435\u043d \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0430 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u0438 \u043f\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e-\u0433\u043e\u0440\u0435 \u043d\u0430\u0447\u0438\u043d. <\/p>\n<p><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0435\u043c\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 who, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u043c <strong>tidyr<\/strong>. \u042d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u0443\u044e \u043c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0437\u0434\u0440\u0430\u0432\u043e\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0442\u0443\u0431\u0435\u0440\u043a\u0443\u043b\u0435\u0437\u043e\u043c.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">who\n# &gt; # A tibble: 7,240 x 60\n# &gt;    country iso2  iso3   year new_sp_m014 new_sp_m1524 new_sp_m2534\n# &gt;        &lt;chr&gt; &lt;int&gt;       &lt;int&gt;        &lt;int&gt;        &lt;int&gt;\n# &gt;  1 Afghan\u2026 AF    AFG    1980          NA           NA           NA\n# &gt;  2 Afghan\u2026 AF    AFG    1981          NA           NA           NA\n# &gt;  3 Afghan\u2026 AF    AFG    1982          NA           NA           NA\n# &gt;  4 Afghan\u2026 AF    AFG    1983          NA           NA           NA\n# &gt;  5 Afghan\u2026 AF    AFG    1984          NA           NA           NA\n# &gt;  6 Afghan\u2026 AF    AFG    1985          NA           NA           NA\n# &gt;  7 Afghan\u2026 AF    AFG    1986          NA           NA           NA\n# &gt;  8 Afghan\u2026 AF    AFG    1987          NA           NA           NA\n# &gt;  9 Afghan\u2026 AF    AFG    1988          NA           NA           NA\n# &gt; 10 Afghan\u2026 AF    AFG    1989          NA           NA           NA\n# &gt; # \u2026 \u0441 7,230 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438 53 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">spec % \n  pivot_longer_spec(new_sp_m014:newrel_f65, values_to = \"count\")<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 56 x 3\n#&gt;    .name        .value name        \n#&gt;    &lt;chr&gt;        &lt;chr&gt;  &lt;chr&gt;       \n#&gt;  1 new_sp_m014  count  new_sp_m014 \n#&gt;  2 new_sp_m1524 count  new_sp_m1524\n#&gt;  3 new_sp_m2534 count  new_sp_m2534\n#&gt;  4 new_sp_m3544 count  new_sp_m3544\n#&gt;  5 new_sp_m4554 count  new_sp_m4554\n#&gt;  6 new_sp_m5564 count  new_sp_m5564\n#&gt;  7 new_sp_m65   count  new_sp_m65  \n#&gt;  8 new_sp_f014  count  new_sp_f014 \n#&gt;  9 new_sp_f1524 count  new_sp_f1524\n#&gt; 10 new_sp_f2534 count  new_sp_f2534\n#&gt; # \u2026 with 46 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u043e\u043b\u0435\u0442\u0430 <em>country<\/em>, <em>iso2<\/em>, <em>iso3<\/em> \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 <em>new_sp_m014<\/em> \u043f\u043e <em>newrel_f65<\/em>.<\/p>\n<p><\/p>\n<p>\u0412 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u0445 \u044d\u0442\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:<\/p>\n<p><\/p>\n<ul>\n<li>\u041f\u0440\u0435\u0444\u0438\u043a\u0441 <code>new_<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u044f \u0442\u0443\u0431\u0435\u0440\u043a\u0443\u043b\u0435\u0437\u043e\u043c, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043e \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u044f\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0435 \u043d\u0435\u0441\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/li>\n<li><code>sp<\/code>\/<code>rel<\/code>\/<code>sp<\/code>\/<code>ep<\/code> \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u044f.<\/li>\n<li><code>m<\/code>\/<code>f<\/code> \u043f\u043e\u043b \u043f\u0430\u0446\u0438\u0435\u043d\u0442\u0430.<\/li>\n<li><code>014<\/code>\/<code>1524<\/code>\/<code>2535<\/code>\/<code>3544<\/code>\/<code>4554<\/code>\/<code>65<\/code> \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u043d\u043e\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u0430\u0446\u0438\u0435\u043d\u0442\u0430.<\/li>\n<\/ul>\n<p><\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u0442\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>extract()<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">spec %\n        extract(name, c(\"diagnosis\", \"gender\", \"age\"), \"new_?(.*)_(.)(.*)\")<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 56 x 5\n#&gt;    .name        .value diagnosis gender age  \n#&gt;    &lt;chr&gt;        &lt;chr&gt;  &lt;chr&gt;     &lt;chr&gt;  &lt;chr&gt;\n#&gt;  1 new_sp_m014  count  sp        m      014  \n#&gt;  2 new_sp_m1524 count  sp        m      1524 \n#&gt;  3 new_sp_m2534 count  sp        m      2534 \n#&gt;  4 new_sp_m3544 count  sp        m      3544 \n#&gt;  5 new_sp_m4554 count  sp        m      4554 \n#&gt;  6 new_sp_m5564 count  sp        m      5564 \n#&gt;  7 new_sp_m65   count  sp        m      65   \n#&gt;  8 new_sp_f014  count  sp        f      014  \n#&gt;  9 new_sp_f1524 count  sp        f      1524 \n#&gt; 10 new_sp_f2534 count  sp        f      2534 \n#&gt; # \u2026 with 46 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0441\u0442\u043e\u043b\u0431\u0435\u0446 <em>.\u0438\u043c\u0435<\/em> \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0430\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p><\/p>\n<p>\u041f\u043e\u043b \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442 (\u0441\u0442\u043e\u043b\u0431\u0446\u044b <em>gender<\/em> \u0438 <em>age<\/em>) \u0438\u043c\u0435\u044e\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0432 \u0444\u0430\u043a\u0442\u043e\u0440\u044b:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">spec %\n            mutate(\n              gender = factor(gender, levels = c(\"f\", \"m\")),\n              age = factor(age, levels = unique(age), ordered = TRUE)\n            ) <\/code><\/pre>\n<p><\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u043c\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0443 <em>who<\/em> , \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <em>spec<\/em> \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_longer()<\/code>.<\/p>\n<p><\/p>\n<p><code>who %&gt;% pivot_longer(spec = spec)<\/code><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 405,440 x 8\n#&gt;    country     iso2  iso3   year diagnosis gender age   count\n#&gt;    &lt;chr&gt;       &lt;chr&gt; &lt;chr&gt; &lt;int&gt; &lt;chr&gt;     &lt;fct&gt;  &lt;ord&gt; &lt;int&gt;\n#&gt;  1 Afghanistan AF    AFG    1980 sp        m      014      NA\n#&gt;  2 Afghanistan AF    AFG    1980 sp        m      1524     NA\n#&gt;  3 Afghanistan AF    AFG    1980 sp        m      2534     NA\n#&gt;  4 Afghanistan AF    AFG    1980 sp        m      3544     NA\n#&gt;  5 Afghanistan AF    AFG    1980 sp        m      4554     NA\n#&gt;  6 Afghanistan AF    AFG    1980 sp        m      5564     NA\n#&gt;  7 Afghanistan AF    AFG    1980 sp        m      65       NA\n#&gt;  8 Afghanistan AF    AFG    1980 sp        f      014      NA\n#&gt;  9 Afghanistan AF    AFG    1980 sp        f      1524     NA\n#&gt; 10 Afghanistan AF    AFG    1980 sp        f      2534     NA\n#&gt; # \u2026 with 405,430 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"R \u043f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0438 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider\" src=\"\/wp-content\/uploads\/2020\/04\/77c8c266c205e1b087738d31de8b8523.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h2 id=\"specifikaciya-s-ispolzovaniem-neskolkih-znacheniyvalue\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043d\u0435 \u043d\u0430 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438 (.value)<\/h2>\n<p><\/p>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 <em>.value<\/em> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e \u0442\u0430\u043a \u0438 \u0431\u044b\u0432\u0430\u0435\u0442. <\/p>\n<p><\/p>\n<p>\u041d\u043e \u043f\u043e\u043d\u044f\u043a\u043e\u0433\u0430 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0432\u044a\u0437\u043d\u0438\u043a\u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0442\u0430 \u0434\u0430 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u0442\u0435 \u0434\u0430\u043d\u043d\u0438 \u043e\u0442 \u043a\u043e\u043b\u043e\u043d\u0438 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0438 \u0442\u0438\u043f\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u0438. \u0421 \u043e\u0441\u0442\u0430\u0440\u044f\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>spread()<\/code> \u0442\u043e\u0432\u0430 \u0431\u0438 \u0431\u0438\u043b\u043e \u0434\u043e\u0441\u0442\u0430 \u0441\u043b\u043e\u0436\u043d\u043e.<\/p>\n<p><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044a\u0442 \u043f\u043e-\u0434\u043e\u043b\u0443 \u0435 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u0430\u043d \u043e\u0442 <noindex><a rel=\"nofollow\" href=\"https:\/\/cran.r-project.org\/web\/packages\/data.table\/vignettes\/datatable-reshape.html\">\u0432\u0438\u043d\u0435\u0442\u043a\u0438<\/a><\/noindex> \u043f\u0430\u043a\u0435\u0442\u0430 <strong>data.table<\/strong>.<\/p>\n<p><\/p>\n<p>\u041d\u0435\u043a\u0430 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u044a\u0447\u0435\u043d \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">family &lt;- tibble::tribble(\n  ~family,  ~dob_child1,  ~dob_child2, ~gender_child1, ~gender_child2,\n       1L, &quot;1998-11-26&quot;, &quot;2000-01-29&quot;,             1L,             2L,\n       2L, &quot;1996-06-22&quot;,           NA,             2L,             NA,\n       3L, &quot;2002-07-11&quot;, &quot;2004-04-05&quot;,             2L,             2L,\n       4L, &quot;2004-10-10&quot;, &quot;2009-08-27&quot;,             1L,             1L,\n       5L, &quot;2000-12-05&quot;, &quot;2005-02-28&quot;,             2L,             1L,\n)\nfamily % mutate_at(vars(starts_with(\"dob\")), parse_date)<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 5 x 5\n#&gt;   family dob_child1 dob_child2 gender_child1 gender_child2\n#&gt;    &lt;int&gt; &lt;date&gt;     &lt;date&gt;             &lt;int&gt;         &lt;int&gt;\n#&gt; 1      1 1998-11-26 2000-01-29             1             2\n#&gt; 2      2 1996-06-22 NA                     2            NA\n#&gt; 3      3 2002-07-11 2004-04-05             2             2\n#&gt; 4      4 2004-10-10 2009-08-27             1             1\n#&gt; 5      5 2000-12-05 2005-02-28             2             1<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u044a\u0437\u0434\u0430\u0434\u0435\u043d\u0438\u044f\u0442 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0434\u0430\u043d\u043d\u0438 \u0437\u0430 \u0434\u0435\u0446\u0430 \u043e\u0442 \u0435\u0434\u043d\u043e \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u0432 \u0440\u0435\u0434\u043e\u0432\u0435\u0442\u0435 \u0441\u0438. \u0412 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430\u0442\u0430 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0438\u043c\u0430 \u0435\u0434\u043d\u043e \u0438\u043b\u0438 \u0434\u0432\u0435 \u0434\u0435\u0446\u0430. \u0417\u0430 \u0432\u0441\u044f\u043a\u043e \u0434\u0435\u0442\u0435 \u0441\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0437\u0430 \u0434\u0430\u0442\u0430 \u043d\u0430 \u0440\u0430\u0436\u0434\u0430\u043d\u0435 \u0438 \u043f\u043e\u043b, \u043a\u0430\u0442\u043e \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u0437\u0430 \u0432\u0441\u0435\u043a\u0438 \u0434\u0435\u0442\u0435\u0442\u043e \u0441\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u043d\u0438 \u043a\u043e\u043b\u043e\u043d\u0438, \u0430 \u043d\u0430\u0448\u0430\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0435 \u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0437\u0438 \u0434\u0430\u043d\u043d\u0438 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442 \u0437\u0430 \u0430\u043d\u0430\u043b\u0438\u0437.<\/p>\n<p><\/p>\n<p>\u041e\u0431\u044a\u0440\u043d\u0435\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0435 \u0438\u043c\u0430\u043c\u0435 \u0434\u0432\u0435 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0438 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0437\u0430 \u0432\u0441\u044f\u043a\u043e \u0434\u0435\u0442\u0435: \u043d\u0435\u0433\u043e\u0432\u0438\u044f \u043f\u043e\u043b \u0438 \u0434\u0430\u0442\u0430 \u043d\u0430 \u0440\u0430\u0436\u0434\u0430\u043d\u0435 (\u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <em>dob<\/em> \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u0442 \u0434\u0430\u0442\u0430 \u043d\u0430 \u0440\u0430\u0436\u0434\u0430\u043d\u0435, \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <em>gender<\/em> \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u0442 \u043f\u043e\u043b\u0430 \u043d\u0430 \u0434\u0435\u0442\u0435\u0442\u043e). \u0412 \u043e\u0447\u0430\u043a\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u0442\u0430\u0442 \u0442\u0435 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0431\u044a\u0434\u0430\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u043d\u0438 \u043a\u043e\u043b\u043e\u043d\u0438. \u041c\u043e\u0436\u0435\u043c \u0434\u0430 \u043f\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u0442\u043e\u0432\u0430, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u0439\u043a\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u0432 \u043a\u043e\u044f\u0442\u043e \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430 <code>.value<\/code> \u0449\u0435 \u0438\u043c\u0430 \u0434\u0432\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">spec %\n  pivot_longer_spec(-family) %&gt;%\n  separate(col = name, into = c(\".value\", \"child\"))%&gt;%\n  mutate(child = parse_number(child))\n<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 4 x 3\n#&gt;   .name         .value child\n#&gt;   &lt;chr&gt;         &lt;chr&gt;  &lt;dbl&gt;\n#&gt; 1 dob_child1    dob        1\n#&gt; 2 dob_child2    dob        2\n#&gt; 3 gender_child1 gender     1\n#&gt; 4 gender_child2 gender     2<\/code><\/pre>\n<p><\/p>\n<p>\u0418 \u0442\u0430\u043a\u0430, \u043d\u0435\u043a\u0430 \u0440\u0430\u0437\u0433\u043b\u0435\u0434\u0430\u043c\u0435 \u0441\u0442\u044a\u043f\u043a\u0438\u0442\u0435, \u043a\u043e\u0438\u0442\u043e \u0441\u0435 \u0438\u0437\u043f\u044a\u043b\u043d\u044f\u0432\u0430\u0442 \u043e\u0442 \u0433\u043e\u0440\u043d\u0438\u044f \u043a\u043e\u0434.<\/p>\n<p><\/p>\n<ul>\n<li><code>pivot_longer_spec(-family)<\/code> \u2014 \u0441\u044a\u0437\u0434\u0430\u0432\u0430\u043c\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u043a\u043e\u044f\u0442\u043e \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0438\u0440\u0430 \u0432\u0441\u0438\u0447\u043a\u0438 \u043d\u0430\u043b\u0438\u0447\u043d\u0438 \u043a\u043e\u043b\u043e\u043d\u0438, \u0441 \u0438\u0437\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430 family.<\/li>\n<li><code>separate(col = name, into = c(\".value\", \"child\"))<\/code> \u2014 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u043c\u0435 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430 <em>.\u0438\u043c\u0435<\/em>, \u043a\u043e\u044f\u0442\u043e \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0438\u043c\u0435\u043d\u0430\u0442\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043d\u0438\u0442\u0435 \u043f\u043e\u043b\u0435\u0442\u0430, \u043f\u043e \u0434\u043e\u043b\u043d\u0430 \u0447\u0435\u0440\u0442\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u0432\u0430\u043c\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0442\u0435 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438 \u0432 \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435 <em>.value<\/em> \u0438 <em>child<\/em>.<\/li>\n<li><code>mutate(child = parse_number(child))<\/code> \u2014 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043c\u0435 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438\u0442\u0435 \u043d\u0430 \u043f\u043e\u043b\u0435\u0442\u043e <em>child<\/em> \u043e\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0432 \u0447\u0438\u0441\u043b\u043e\u0432 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u0438.<\/li>\n<\/ul>\n<p><\/p>\n<p>\u0421\u0435\u0433\u0430 \u043c\u043e\u0436\u0435\u043c \u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430\u0442\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043a\u044a\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043d\u0438\u044f \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0438 \u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0442\u0430 \u0432 \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0432\u0438\u0434.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">family %&gt;% \n    pivot_longer(spec = spec, na.rm = T)<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 9 x 4\n#&gt;   family child dob        gender\n#&gt;    &lt;int&gt; &lt;dbl&gt; &lt;date&gt;      &lt;int&gt;\n#&gt; 1      1     1 1998-11-26      1\n#&gt; 2      1     2 2000-01-29      2\n#&gt; 3      2     1 1996-06-22      2\n#&gt; 4      3     1 2002-07-11      2\n#&gt; 5      3     2 2004-04-05      2\n#&gt; 6      4     1 2004-10-10      1\n#&gt; 7      4     2 2009-08-27      1\n#&gt; 8      5     1 2000-12-05      2\n#&gt; 9      5     2 2005-02-28      1<\/code><\/pre>\n<p><\/p>\n<p>\u0418\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043c\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <code>na.rm = TRUE<\/code>, \u0437\u0430\u0449\u043e\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0430\u0442\u0430 \u0444\u043e\u0440\u043c\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u043f\u0440\u0438\u043d\u0443\u0436\u0434\u0430\u0432\u0430 \u0434\u0430 \u0441\u0435 \u0441\u044a\u0437\u0434\u0430\u0432\u0430\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u0438 \u0440\u0435\u0434\u043e\u0432\u0435 \u0437\u0430 \u043d\u0435\u0441\u044a\u0449\u0435\u0441\u0442\u0432\u0443\u0432\u0430\u0449\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f. \u0422\u044a\u0439 \u043a\u0430\u0442\u043e \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e\u0442\u043e 2 \u0438\u043c\u0430 \u0441\u0430\u043c\u043e \u0435\u0434\u043d\u043e \u0434\u0435\u0442\u0435, <code>na.rm = TRUE<\/code> \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0430, \u0447\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e 2 \u0449\u0435 \u0438\u043c\u0430 \u0435\u0434\u0438\u043d \u0440\u0435\u0434 \u0432 \u0438\u0437\u0445\u043e\u0434\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u0438.<\/p>\n<p><\/p>\n<h2 id=\"preobrazovanie-data-freymov-iz-dlinnogo-formata-k-shirokomu\">\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u043e\u0432\u0435 \u043e\u0442 \u0434\u044a\u043b\u044a\u0433 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432 \u0448\u0438\u0440\u043e\u043a<\/h2>\n<p><\/p>\n<p><code>pivot_wider()<\/code> \u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0430\u0432\u0430 \u0431\u0440\u043e\u044f \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435 \u0432 \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u0430, \u043d\u0430\u043c\u0430\u043b\u044f\u0432\u0430\u0439\u043a\u0438 \u0431\u0440\u043e\u044f \u043d\u0430 \u0440\u0435\u0434\u043e\u0432\u0435\u0442\u0435.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"R \u043f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0438 \u043d\u0435\u0433\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider\" src=\"\/wp-content\/uploads\/2020\/04\/b470664e06f362d6f0ea6df9c1ed426d.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>\u0422\u043e\u0437\u0438 \u0442\u0438\u043f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435 \u0441\u0435 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430 \u0438\u0437\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u043d\u043e \u0440\u044f\u0434\u043a\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044f\u043d\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u0432 \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u0432\u0438\u0434, \u043d\u043e \u0432\u0441\u0435 \u043f\u0430\u043a \u0442\u043e\u0437\u0438 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0431\u044a\u0434\u0435 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0437\u0430 \u0441\u044a\u0437\u0434\u0430\u0432\u0430\u043d\u0435 \u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0438, \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043d\u0438 \u0432 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0438\u043b\u0438 \u0437\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 \u0434\u0440\u0443\u0433\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438.<\/p>\n<p><\/p>\n<p>\u0412\u0441\u044a\u0449\u043d\u043e\u0441\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0442\u0435 <code>pivot_longer()<\/code> \u0438 <code>pivot_wider()<\/code> \u0441\u0430 \u0441\u0438\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0438 \u0438 \u0438\u0437\u0432\u044a\u0440\u0448\u0432\u0430\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442.\u0435: <code>df %&gt;% pivot_longer(spec = spec) %&gt;% pivot_wider(spec = spec)<\/code> \u0438 <code>df %&gt;% pivot_wider(spec = spec) %&gt;% pivot_longer(spec = spec)<\/code> \u0449\u0435 \u0432\u044a\u0440\u043d\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043d\u0438\u044f df.<\/p>\n<p><\/p>\n<h3 id=\"prosteyshiy-primer-privedeniya-tablicy-k-shirokomu-formatu\">\u041d\u0430\u0439-\u043f\u0440\u043e\u0441\u0442\u0438\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u043f\u0440\u0435\u0432\u0435\u0436\u0434\u0430\u043d\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0448\u0438\u0440\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442<\/h3>\n<p><\/p>\n<p>\u0417\u0430 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u0430 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_wider()<\/code> \u0449\u0435 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043c\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 <em>fish_encounters<\/em>, \u0432 \u043a\u043e\u0439\u0442\u043e \u0441\u0435 \u0441\u044a\u0445\u0440\u0430\u043d\u044f\u0432\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0437\u0430 \u0442\u043e\u0432\u0430 \u043a\u0430\u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0438 \u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0430\u0442 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u0442\u043e \u043d\u0430 \u0440\u0438\u0431\u0438\u0442\u0435 \u043f\u043e \u0440\u0435\u043a\u0430\u0442\u0430.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 114 x 3\n#&gt;    fish  station  seen\n#&gt;    &lt;fct&gt; &lt;fct&gt;   &lt;int&gt;\n#&gt;  1 4842  Release     1\n#&gt;  2 4842  I80_1       1\n#&gt;  3 4842  Lisbon      1\n#&gt;  4 4842  Rstr        1\n#&gt;  5 4842  Base_TD     1\n#&gt;  6 4842  BCE         1\n#&gt;  7 4842  BCW         1\n#&gt;  8 4842  BCE2        1\n#&gt;  9 4842  BCW2        1\n#&gt; 10 4842  MAE         1\n#&gt; # \u2026 with 104 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u0412 \u043f\u043e\u0432\u0435\u0447\u0435\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0438, \u0442\u0430\u0437\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0449\u0435 \u0431\u044a\u0434\u0435 \u043f\u043e-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u0430 \u0438 \u0443\u0434\u043e\u0431\u043d\u0430 \u0437\u0430 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u0430, \u0430\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f\u0442\u0430 \u0437\u0430 \u0432\u0441\u044f\u043a\u0430 \u0441\u0442\u0430\u043d\u0446\u0438\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430.<\/p>\n<p><\/p>\n<p><code>fish_encounters %&gt;% pivot_wider(names_from = station, values_from = seen)<\/code><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">fish_encounters %&gt;% pivot_wider(names_from = station, values_from = seen)\n#&gt; # A tibble: 19 x 12\n#&gt;    fish  Release I80_1 Lisbon  Rstr Base_TD   BCE   BCW  BCE2  BCW2   MAE\n#&gt;        &amp;        &amp; &amp; &amp;  \n#&gt;  1 4842        1     1      1     1       1     1     1     1     1     1\n#&gt;  2 4843        1     1      1     1       1     1     1     1     1     1\n#&gt;  3 4844        1     1      1     1       1     1     1     1     1     1\n#&gt;  4 4845        1     1      1     1       1    NA    NA    NA    NA    NA\n#&gt;  5 4847        1     1      1    NA      NA    NA    NA    NA    NA    NA\n#&gt;  6 4848        1     1      1     1      NA    NA    NA    NA    NA    NA\n#&gt;  7 4849        1     1     NA    NA      NA    NA    NA    NA    NA    NA\n#&gt;  8 4850        1     1     NA     1       1     1     1    NA    NA    NA\n#&gt;  9 4851        1     1     NA    NA      NA    NA    NA    NA    NA    NA\n#&gt; 10 4854        1     1     NA    NA      NA    NA    NA    NA    NA    NA\n#&gt; # \u2026 \u0441 9 \u0434\u043e\u043f\u044a\u043b\u043d\u0438\u0442\u0435\u043b\u043d\u0438 \u0440\u0435\u0434\u0430 \u0438 1 \u0434\u043e\u043f\u044a\u043b\u043d\u0438\u0442\u0435\u043b\u043d\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430: MAW<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u043e\u0437\u0438 \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u0437\u0430\u043f\u0438\u0441\u0432\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0441\u0430\u043c\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0438\u0442\u0435, \u043a\u043e\u0433\u0430\u0442\u043e \u0440\u0438\u0431\u0430\u0442\u0430 \u0435 \u0431\u0438\u043b\u0430 \u043e\u0442\u043a\u0440\u0438\u0442\u0430 \u043e\u0442 \u0441\u0442\u0430\u043d\u0446\u0438\u044f\u0442\u0430, \u0442.\u0435. \u0430\u043a\u043e \u043d\u044f\u043a\u043e\u044f \u0440\u0438\u0431\u0430 \u043d\u0435 \u0435 \u0431\u0438\u043b\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0430\u043d\u0430 \u043e\u0442 \u043d\u044f\u043a\u043e\u044f \u0441\u0442\u0430\u043d\u0446\u0438\u044f, \u0442\u0430\u043a\u0430\u0432\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u044a\u0449\u0435\u0441\u0442\u0432\u0443\u0432\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0442\u0430. \u0422\u043e\u0432\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0432\u0430, \u0447\u0435 \u0438\u0437\u0445\u043e\u0434\u043d\u0438\u044f\u0442 \u043d\u0430\u0431\u043e\u0440 \u0449\u0435 \u0431\u044a\u0434\u0435 \u043f\u043e\u043f\u044a\u043b\u043d\u0435\u043d \u0441 NA. <\/p>\n<p><\/p>\n<p>\u0412\u044a\u043f\u0440\u0435\u043a\u0438 \u0442\u043e\u0432\u0430, \u0432 \u0442\u043e\u0437\u0438 \u0441\u043b\u0443\u0447\u0430\u0439 \u0437\u043d\u0430\u0435\u043c, \u0447\u0435 \u043b\u0438\u043f\u0441\u0430\u0442\u0430 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441 \u043e\u0437\u043d\u0430\u0447\u0430\u0432\u0430, \u0447\u0435 \u0440\u0438\u0431\u0430\u0442\u0430 \u043d\u0435 \u0435 \u0431\u0438\u043b\u0430 \u0437\u0430\u0431\u0435\u043b\u044f\u0437\u0430\u043d\u0430, \u0442\u0430\u043a\u0430 \u0447\u0435 \u043c\u043e\u0436\u0435\u043c \u0434\u0430 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043c\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <em>values_fill<\/em> \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_wider()<\/code> \u0438 \u0434\u0430 \u0437\u0430\u043f\u044a\u043b\u043d\u0438\u043c \u0442\u0435\u0437\u0438 \u043b\u0438\u043f\u0441\u0432\u0430\u0449\u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438 \u0441 \u043d\u0443\u043b\u0438:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">fish_encounters %&gt;% pivot_wider(\n  names_from = station,\n  values_from = seen,\n  values_fill = list(seen = 0)\n)<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 19 x 12\n#&gt;    fish  Release I80_1 Lisbon  Rstr Base_TD   BCE   BCW  BCE2  BCW2   MAE\n#&gt;    &lt;fct&gt;   &lt;int&gt; &lt;int&gt;  &lt;int&gt; &lt;int&gt;   &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;\n#&gt;  1 4842        1     1      1     1       1     1     1     1     1     1\n#&gt;  2 4843        1     1      1     1       1     1     1     1     1     1\n#&gt;  3 4844        1     1      1     1       1     1     1     1     1     1\n#&gt;  4 4845        1     1      1     1       1     0     0     0     0     0\n#&gt;  5 4847        1     1      1     0       0     0     0     0     0     0\n#&gt;  6 4848        1     1      1     1       0     0     0     0     0     0\n#&gt;  7 4849        1     1      0     0       0     0     0     0     0     0\n#&gt;  8 4850        1     1      0     1       1     1     1     0     0     0\n#&gt;  9 4851        1     1      0     0       0     0     0     0     0     0\n#&gt; 10 4854        1     1      0     0       0     0     0     0     0     0\n#&gt; # \u2026 with 9 more rows, and 1 more variable: MAW &lt;int&gt;<\/code><\/pre>\n<p><\/p>\n<h3 id=\"generaciya-imeni-stolbca-iz-neskolkih-ishodnyh-peremennyh\">\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u0438\u043c\u0435 \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430 \u043e\u0442 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0438\u0437\u0445\u043e\u0434\u043d\u0438 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0438<\/h3>\n<p><\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0435\u0442\u0435 \u0441\u0438, \u0447\u0435 \u0438\u043c\u0430\u043c\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u0449\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442, \u0441\u0442\u0440\u0430\u043d\u0430 \u0438 \u0433\u043e\u0434\u0438\u043d\u0430. \u0417\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430 \u0438\u0437\u043f\u044a\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u043d\u0438\u044f \u043a\u043e\u0434:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">df %\n  filter((product == \"A\" &amp; country == \"AI\") | product == \"B\") %&gt;% \n  mutate(value = rnorm(nrow(.)))<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 45 x 4\n#&gt;    product country  year    value\n#&gt;    &lt;chr&gt;   &lt;chr&gt;   &lt;int&gt;    &lt;dbl&gt;\n#&gt;  1 A       AI       2000 -2.05   \n#&gt;  2 A       AI       2001 -0.676  \n#&gt;  3 A       AI       2002  1.60   \n#&gt;  4 A       AI       2003 -0.353  \n#&gt;  5 A       AI       2004 -0.00530\n#&gt;  6 A       AI       2005  0.442  \n#&gt;  7 A       AI       2006 -0.610  \n#&gt;  8 A       AI       2007 -2.77   \n#&gt;  9 A       AI       2008  0.899  \n#&gt; 10 A       AI       2009 -0.106  \n#&gt; # \u2026 with 35 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u041d\u0430\u0448\u0430\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0435 \u0434\u0430 \u0440\u0430\u0437\u0448\u0438\u0440\u0438\u043c \u0434\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u0430 \u0442\u0430\u043a\u0430, \u0447\u0435 \u0435\u0434\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430 \u0434\u0430 \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0434\u0430\u043d\u043d\u0438 \u0437\u0430 \u0432\u0441\u044f\u043a\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0438 \u0441\u0442\u0440\u0430\u043d\u0430. \u0417\u0430 \u0442\u043e\u0432\u0430 \u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u044a\u0447\u043d\u043e \u0434\u0430 \u043f\u043e\u0434\u0430\u0434\u0435\u043c \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <em>names_from<\/em> \u0432\u0435\u043a\u0442\u043e\u0440, \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u0449 \u0438\u043c\u0435\u043d\u0430\u0442\u0430 \u043d\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0430\u043d\u0438\u0442\u0435 \u043f\u043e\u043b\u0435\u0442\u0430.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">df %&gt;% pivot_wider(names_from = c(product, country),\n                 values_from = \"value\")<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 15 x 4\n#&gt;     year     A_AI    B_AI    B_EI\n#&gt;    &lt;int&gt;    &lt;dbl&gt;   &lt;dbl&gt;   &lt;dbl&gt;\n#&gt;  1  2000 -2.05     0.607   1.20  \n#&gt;  2  2001 -0.676    1.65   -0.114 \n#&gt;  3  2002  1.60    -0.0245  0.501 \n#&gt;  4  2003 -0.353    1.30   -0.459 \n#&gt;  5  2004 -0.00530  0.921  -0.0589\n#&gt;  6  2005  0.442   -1.55    0.594 \n#&gt;  7  2006 -0.610    0.380  -1.28  \n#&gt;  8  2007 -2.77     0.830   0.637 \n#&gt;  9  2008  0.899    0.0175 -1.30  \n#&gt; 10  2009 -0.106   -0.195   1.03  \n#&gt; # \u2026 with 5 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u044a\u0449\u043e \u0442\u0430\u043a\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_wider()<\/code>. \u041d\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u0430\u0432\u0430\u043d\u0435\u0442\u043e \u0432 <code>pivot_wider()<\/code> \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0442\u0430 \u0438\u0437\u0432\u044a\u0440\u0448\u0432\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435, \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e \u043d\u0430 <code>pivot_longer()<\/code>: \u0441\u044a\u0437\u0434\u0430\u0432\u0430\u0442 \u0441\u0435 \u043a\u043e\u043b\u043e\u043d\u0438\u0442\u0435, \u043f\u043e\u0441\u043e\u0447\u0435\u043d\u0438 \u0432 <em>.\u0438\u043c\u0435<\/em>, \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u0439\u043a\u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438\u0442\u0435 \u043e\u0442 <em>.value<\/em> \u0438 \u0434\u0440\u0443\u0433\u0438 \u043a\u043e\u043b\u043e\u043d\u0438.<\/p>\n<p><\/p>\n<p>\u0417\u0430 \u0442\u043e\u0437\u0438 \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u0442\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0441\u043a\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u0430\u043a\u043e \u0438\u0441\u043a\u0430\u0442\u0435 \u0432\u0441\u044f\u043a\u0430 \u0432\u044a\u0437\u043c\u043e\u0436\u043d\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043e\u0442 \u0441\u0442\u0440\u0430\u043d\u0430 \u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0434\u0430 \u0438\u043c\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430, \u0430 \u043d\u0435 \u0441\u0430\u043c\u043e \u0442\u0435\u0437\u0438, \u043a\u043e\u0438\u0442\u043e \u043f\u0440\u0438\u0441\u044a\u0441\u0442\u0432\u0430\u0442 \u0432 \u0434\u0430\u043d\u043d\u0438\u0442\u0435:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">spec % \n  expand(product, country, .value = \"value\") %&gt;% \n  unite(\".name\", product, country, remove = FALSE)<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 4 x 4\n#&gt;   .name product country .value\n#&gt;   &lt;chr&gt; &lt;chr&gt;   &lt;chr&gt;   &lt;chr&gt; \n#&gt; 1 A_AI  A       AI      value \n#&gt; 2 A_EI  A       EI      value \n#&gt; 3 B_AI  B       AI      value \n#&gt; 4 B_EI  B       EI      value<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">df %&gt;% pivot_wider(spec = spec) %&gt;% head()<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 6 x 5\n#&gt;    year     A_AI  A_EI    B_AI    B_EI\n#&gt;   &lt;int&gt;    &lt;dbl&gt; &lt;dbl&gt;   &lt;dbl&gt;   &lt;dbl&gt;\n#&gt; 1  2000 -2.05       NA  0.607   1.20  \n#&gt; 2  2001 -0.676      NA  1.65   -0.114 \n#&gt; 3  2002  1.60       NA -0.0245  0.501 \n#&gt; 4  2003 -0.353      NA  1.30   -0.459 \n#&gt; 5  2004 -0.00530    NA  0.921  -0.0589\n#&gt; 6  2005  0.442      NA -1.55    0.594<\/code><\/pre>\n<p><\/p>\n<h2 id=\"neskolko-prodvinutyh-primerov-raboty-s-novoy-koncepciey-tidyr\">\u041d\u044f\u043a\u043e\u043b\u043a\u043e \u043d\u0430\u043f\u0440\u0435\u0434\u043d\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043d\u043e\u0432\u0430\u0442\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u043d\u0430 tidyr<\/h2>\n<p><\/p>\n<h3 id=\"privedenie-dannyh-k-akkuratnomu-vidu-na-primere-nabora-dannyh-o-perepisi-dohoda-i-arendnoy-platy-v-ssha\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u0438 \u0432 \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u0432\u0438\u0434 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430 \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u0437\u0430 \u0434\u043e\u0445\u043e\u0434\u0438 \u0438 \u043d\u0430\u0435\u043c\u0438 \u0432 \u0421\u0410\u0429<\/h3>\n<p><\/p>\n<p>\u041d\u0430\u0431\u043e\u0440\u044a\u0442 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 <em>us_rent_income<\/em> \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0437\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u044f \u0434\u043e\u0445\u043e\u0434 \u0438 \u043d\u0430\u0435\u043c \u0437\u0430 \u0432\u0441\u0435\u043a\u0438 \u0449\u0430\u0442 \u0432 \u0421\u0410\u0429 \u0437\u0430 2017 \u0433\u043e\u0434\u0438\u043d\u0430 (\u043d\u0430\u0431\u043e\u0440\u044a\u0442 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u0435 \u043d\u0430\u043b\u0438\u0447\u0435\u043d \u0432 \u043f\u0430\u043a\u0435\u0442\u0430 <strong>tidycensus<\/strong>).<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">us_rent_income\n#&gt; # A tibble: 104 x 5\n#&gt;    GEOID NAME       variable estimate   moe\n#&gt;                   \n#&gt;  1 01    Alabama    income      24476   136\n#&gt;  2 01    Alabama    rent          747     3\n#&gt;  3 02    Alaska     income      32940   508\n#&gt;  4 02    Alaska     rent         1200    13\n#&gt;  5 04    Arizona    income      27517   148\n#&gt;  6 04    Arizona    rent          972     4\n#&gt;  7 05    Arkansas   income      23789   165\n#&gt;  8 05    Arkansas   rent          709     5\n#&gt;  9 06    California income      29454   109\n#&gt; 10 06    California rent         1358     3\n#&gt; # \u2026 \u0441 94 \u043e\u0449\u0435 \u0440\u0435\u0434\u0430<\/code><\/pre>\n<p><\/p>\n<p>\u0412 \u0441\u0435\u0433\u0430\u0448\u043d\u0438\u044f\u0442 \u0432\u0438\u0434, \u0432 \u043a\u043e\u0439\u0442\u043e \u0441\u0435 \u0441\u044a\u0445\u0440\u0430\u043d\u044f\u0432\u0430\u0442 \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u0432 \u043d\u0430\u0431\u043e\u0440\u0430 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 <em>us_rent_income<\/em> \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u0430 \u0441 \u0442\u044f\u0445 \u0435 \u0438\u0437\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u043d\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u0430, \u0437\u0430\u0442\u043e\u0432\u0430 \u0431\u0438\u0445\u043c\u0435 \u0436\u0435\u043b\u0430\u043b\u0438 \u0434\u0430 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u0441 \u043a\u043e\u043b\u043e\u043d\u0438: <em>rent<\/em>, <em>rent_moe<\/em>, <em>come<\/em>, <em>income_moe<\/em>. \u0421\u044a\u0449\u0435\u0441\u0442\u0432\u0443\u0432\u0430\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0447\u0438\u043d\u0438 \u0437\u0430 \u0441\u044a\u0437\u0434\u0430\u0432\u0430\u043d\u0435 \u043d\u0430 \u0442\u0430\u0437\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0438\u044f\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435, \u0447\u0435 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043c\u0435 \u0432\u0441\u044f\u043a\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043e\u0442 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438\u0442\u0435 \u043d\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430\u0442\u0430 \u0438 <em>estimate\/moe<\/em>, \u0430 \u0441\u043b\u0435\u0434 \u0442\u043e\u0432\u0430 \u0434\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043c\u0435 \u0438\u043c\u0435\u0442\u043e \u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">  spec % \n    expand(variable, .value = c(\"estimate\", \"moe\")) %&gt;% \n    mutate(\n      .name = paste0(variable, ifelse(.value == \"moe\", \"_moe\", \"\"))\n    )<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 4 x 3\n#&gt;   variable .value   .name     \n#&gt;   &lt;chr&gt;    &lt;chr&gt;    &lt;chr&gt;     \n#&gt; 1 income   estimate income    \n#&gt; 2 income   moe      income_moe\n#&gt; 3 rent     estimate rent      \n#&gt; 4 rent     moe      rent_moe<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u044f\u043d\u0435\u0442\u043e \u043d\u0430 \u0442\u0430\u0437\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f <code>pivot_wider()<\/code> \u0434\u0430\u0432\u0430 \u0440\u0435\u0437\u0443\u043b\u0442\u0430\u0442\u0430, \u043a\u043e\u0439\u0442\u043e \u0442\u044a\u0440\u0441\u0438\u043c:<\/p>\n<p><\/p>\n<p><code>us_rent_income %&gt;% pivot_wider(spec = spec)<\/code><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 52 x 6\n#&gt;    GEOID NAME                 income income_moe  rent rent_moe\n#&gt;    &lt;chr&gt; &lt;chr&gt;                 &lt;dbl&gt;      &lt;dbl&gt; &lt;dbl&gt;    &lt;dbl&gt;\n#&gt;  1 01    Alabama               24476        136   747        3\n#&gt;  2 02    Alaska                32940        508  1200       13\n#&gt;  3 04    Arizona               27517        148   972        4\n#&gt;  4 05    Arkansas              23789        165   709        5\n#&gt;  5 06    California            29454        109  1358        3\n#&gt;  6 08    Colorado              32401        109  1125        5\n#&gt;  7 09    Connecticut           35326        195  1123        5\n#&gt;  8 10    Delaware              31560        247  1076       10\n#&gt;  9 11    District of Columbia  43198        681  1424       17\n#&gt; 10 12    Florida               25952         70  1077        3\n#&gt; # \u2026 with 42 more rows<\/code><\/pre>\n<p><\/p>\n<h3 id=\"vsemirnyy-bank\">\u0421\u0432\u0435\u0442\u043e\u0432\u043d\u0430\u0442\u0430 \u0431\u0430\u043d\u043a\u0430<\/h3>\n<p><\/p>\n<p>\u041f\u043e\u043d\u044f\u043a\u043e\u0433\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438 \u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u0442\u0430 \u0444\u043e\u0440\u043c\u0430 \u0438\u0437\u0438\u0441\u043a\u0432\u0430 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0441\u0442\u044a\u043f\u043a\u0438.<br \/>\n\u0414\u0430\u0442\u0430\u0441\u0435\u0442 <em>world_bank_pop<\/em> \u0441\u044a\u0434\u044a\u0440\u0436\u0430 \u0434\u0430\u043d\u043d\u0438 \u043d\u0430 \u0421\u0432\u0435\u0442\u043e\u0432\u043d\u0430\u0442\u0430 \u0431\u0430\u043d\u043a\u0430 \u0437\u0430 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u0435\u0442\u043e \u043d\u0430 \u0432\u0441\u044f\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u0430 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u043e\u0442 2000 \u0434\u043e 2018 \u0433\u043e\u0434\u0438\u043d\u0430.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 1,056 x 20\n#&gt;    country indicator `2000` `2001` `2002` `2003`  `2004`  `2005`   `2006`\n#&gt;    &lt;chr&gt;   &lt;chr&gt;      &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;   &lt;dbl&gt;   &lt;dbl&gt;    &lt;dbl&gt;\n#&gt;  1 ABW     SP.URB.T\u2026 4.24e4 4.30e4 4.37e4 4.42e4 4.47e+4 4.49e+4  4.49e+4\n#&gt;  2 ABW     SP.URB.G\u2026 1.18e0 1.41e0 1.43e0 1.31e0 9.51e-1 4.91e-1 -1.78e-2\n#&gt;  3 ABW     SP.POP.T\u2026 9.09e4 9.29e4 9.50e4 9.70e4 9.87e+4 1.00e+5  1.01e+5\n#&gt;  4 ABW     SP.POP.G\u2026 2.06e0 2.23e0 2.23e0 2.11e0 1.76e+0 1.30e+0  7.98e-1\n#&gt;  5 AFG     SP.URB.T\u2026 4.44e6 4.65e6 4.89e6 5.16e6 5.43e+6 5.69e+6  5.93e+6\n#&gt;  6 AFG     SP.URB.G\u2026 3.91e0 4.66e0 5.13e0 5.23e0 5.12e+0 4.77e+0  4.12e+0\n#&gt;  7 AFG     SP.POP.T\u2026 2.01e7 2.10e7 2.20e7 2.31e7 2.41e+7 2.51e+7  2.59e+7\n#&gt;  8 AFG     SP.POP.G\u2026 3.49e0 4.25e0 4.72e0 4.82e0 4.47e+0 3.87e+0  3.23e+0\n#&gt;  9 AGO     SP.URB.T\u2026 8.23e6 8.71e6 9.22e6 9.77e6 1.03e+7 1.09e+7  1.15e+7\n#&gt; 10 AGO     SP.URB.G\u2026 5.44e0 5.59e0 5.70e0 5.76e0 5.75e+0 5.69e+0  4.92e+0\n#&gt; # \u2026 with 1,046 more rows, and 11 more variables: `2007` &lt;dbl&gt;,\n#&gt; #   `2008` &lt;dbl&gt;, `2009` &lt;dbl&gt;, `2010` &lt;dbl&gt;, `2011` &lt;dbl&gt;, `2012` &lt;dbl&gt;,\n#&gt; #   `2013` &lt;dbl&gt;, `2014` &lt;dbl&gt;, `2015` &lt;dbl&gt;, `2016` &lt;dbl&gt;, `2017` &lt;dbl&gt;<\/code><\/pre>\n<p><\/p>\n<p>\u041d\u0430\u0448\u0430\u0442\u0430 \u0446\u0435\u043b \u0435 \u0434\u0430 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043c \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u043d\u0430\u0431\u043e\u0440 \u043e\u0442 \u0434\u0430\u043d\u043d\u0438, \u043f\u0440\u0438 \u043a\u043e\u0439\u0442\u043e \u0432\u0441\u044f\u043a\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430 \u0434\u0430 \u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u0430. \u0412\u0441\u0435 \u043e\u0449\u0435 \u043d\u0435 \u0435 \u044f\u0441\u043d\u043e \u043a\u0430\u043a\u0432\u0438 \u0442\u043e\u0447\u043d\u043e \u0441\u0442\u044a\u043f\u043a\u0438 \u0441\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0438, \u043d\u043e \u0449\u0435 \u0437\u0430\u043f\u043e\u0447\u043d\u0435\u043c \u0441 \u043d\u0430\u0439-\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c: \u0433\u043e\u0434\u0438\u043d\u0430\u0442\u0430 \u0435 \u0440\u0430\u0437\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0432 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u043a\u043e\u043b\u043e\u043d\u0438.<\/p>\n<p><\/p>\n<p>\u0417\u0430 \u0434\u0430 \u0433\u043e \u043a\u043e\u0440\u0438\u0433\u0438\u0440\u0430\u043c\u0435, \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>pivot_longer()<\/code>.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">pop2 % \n  pivot_longer(`2000`:`2017`, names_to = \"year\")<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 19,008 x 4\n#&gt;    country indicator   year  value\n#&gt;    &lt;chr&gt;   &lt;chr&gt;       &lt;chr&gt; &lt;dbl&gt;\n#&gt;  1 ABW     SP.URB.TOTL 2000  42444\n#&gt;  2 ABW     SP.URB.TOTL 2001  43048\n#&gt;  3 ABW     SP.URB.TOTL 2002  43670\n#&gt;  4 ABW     SP.URB.TOTL 2003  44246\n#&gt;  5 ABW     SP.URB.TOTL 2004  44669\n#&gt;  6 ABW     SP.URB.TOTL 2005  44889\n#&gt;  7 ABW     SP.URB.TOTL 2006  44881\n#&gt;  8 ABW     SP.URB.TOTL 2007  44686\n#&gt;  9 ABW     SP.URB.TOTL 2008  44375\n#&gt; 10 ABW     SP.URB.TOTL 2009  44052\n#&gt; # \u2026 with 18,998 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u043b\u0435\u0434\u0432\u0430\u0449\u0430\u0442\u0430 \u0441\u0442\u044a\u043f\u043a\u0430 \u0435 \u0434\u0430 \u0440\u0430\u0437\u0433\u043b\u0435\u0434\u0430\u043c\u0435 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430\u0442\u0430 indicator.<br \/>\n<code>pop2 %&gt;% count(indicator)<\/code><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 4 x 2\n#&gt;   indicator       n\n#&gt;   &lt;chr&gt;       &lt;int&gt;\n#&gt; 1 SP.POP.GROW  4752\n#&gt; 2 SP.POP.TOTL  4752\n#&gt; 3 SP.URB.GROW  4752\n#&gt; 4 SP.URB.TOTL  4752<\/code><\/pre>\n<p><\/p>\n<p>\u041a\u044a\u0434\u0435\u0442\u043e SP.POP.GROW \u0435 \u0440\u0430\u0441\u0442\u0435\u0436 \u043d\u0430 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u0435\u0442\u043e, SP.POP.TOTL \u0435 \u043e\u0431\u0449\u0438\u044f\u0442 \u0431\u0440\u043e\u0439 \u043d\u0430 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u0435\u0442\u043e, \u0430 SP.URB. * \u0435 \u0441\u044a\u0449\u043e\u0442\u043e, \u043d\u043e \u0441\u0430\u043c\u043e \u0437\u0430 \u0433\u0440\u0430\u0434\u0441\u043a\u0438\u0442\u0435 \u0440\u0430\u0439\u043e\u043d\u0438. \u041d\u0435\u043a\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0442\u0435\u0437\u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0434\u0432\u0435 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0438: area \u2014 \u043c\u0435\u0441\u0442\u043d\u043e\u0441\u0442 (total \u0438\u043b\u0438 urban) \u0438 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430\u0442\u0430, \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u0449\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u0438 (population \u0438\u043b\u0438 growth):<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">pop3 % \n  separate(indicator, c(NA, \"area\", \"variable\"))<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 19,008 x 5\n#&gt;    country area  variable year  value\n#&gt;    &lt;chr&gt;   &lt;chr&gt; &lt;chr&gt;    &lt;chr&gt; &lt;dbl&gt;\n#&gt;  1 ABW     URB   TOTL     2000  42444\n#&gt;  2 ABW     URB   TOTL     2001  43048\n#&gt;  3 ABW     URB   TOTL     2002  43670\n#&gt;  4 ABW     URB   TOTL     2003  44246\n#&gt;  5 ABW     URB   TOTL     2004  44669\n#&gt;  6 ABW     URB   TOTL     2005  44889\n#&gt;  7 ABW     URB   TOTL     2006  44881\n#&gt;  8 ABW     URB   TOTL     2007  44686\n#&gt;  9 ABW     URB   TOTL     2008  44375\n#&gt; 10 ABW     URB   TOTL     2009  44052\n#&gt; # \u2026 with 18,998 more rows<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u0435\u0433\u0430 \u043e\u0441\u0442\u0430\u0432\u0430 \u0441\u0430\u043c\u043e \u0434\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430\u0442\u0430 variable \u043d\u0430 \u0434\u0432\u0435 \u043a\u043e\u043b\u043e\u043d\u0438:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">pop3 %&gt;% \n  pivot_wider(names_from = variable, values_from = value)<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 9,504 x 5\n#&gt;    country area  year   TOTL    GROW\n#&gt;    &lt;chr&gt;   &lt;chr&gt; &lt;chr&gt; &lt;dbl&gt;   &lt;dbl&gt;\n#&gt;  1 ABW     URB   2000  42444  1.18  \n#&gt;  2 ABW     URB   2001  43048  1.41  \n#&gt;  3 ABW     URB   2002  43670  1.43  \n#&gt;  4 ABW     URB   2003  44246  1.31  \n#&gt;  5 ABW     URB   2004  44669  0.951 \n#&gt;  6 ABW     URB   2005  44889  0.491 \n#&gt;  7 ABW     URB   2006  44881 -0.0178\n#&gt;  8 ABW     URB   2007  44686 -0.435 \n#&gt;  9 ABW     URB   2008  44375 -0.698 \n#&gt; 10 ABW     URB   2009  44052 -0.731 \n#&gt; # \u2026 with 9,494 more rows<\/code><\/pre>\n<p><\/p>\n<h3 id=\"spisok-kontaktov\">\u0421\u043f\u0438\u0441\u044a\u043a \u0441 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0438<\/h3>\n<p><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0435\u0442\u0435 \u0441\u0438, \u0447\u0435 \u0438\u043c\u0430\u0442\u0435 \u0441\u043f\u0438\u0441\u044a\u043a \u0441 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0438, \u043a\u043e\u0439\u0442\u043e \u0441\u0442\u0435 \u043a\u043e\u043f\u0438\u0440\u0430\u043b\u0438 \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043e\u0442 \u0443\u0435\u0431\u0441\u0430\u0439\u0442:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">contacts &lt;- tribble(\n  ~field, ~value,\n  &quot;name&quot;, &quot;Jiena McLellan&quot;,\n  &quot;company&quot;, &quot;Toyota&quot;, \n  &quot;name&quot;, &quot;John Smith&quot;, \n  &quot;company&quot;, &quot;google&quot;, \n  &quot;email&quot;, &quot;john@google.com&quot;,\n  &quot;name&quot;, &quot;Huxley Ratcliffe&quot;\n)<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u0440\u0443\u0434\u043d\u043e \u0435 \u0434\u0430 \u0441\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430 \u0442\u043e\u0437\u0438 \u0441\u043f\u0438\u0441\u044a\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0437\u0430\u0449\u043e\u0442\u043e \u043d\u044f\u043c\u0430 \u043f\u0440\u043e\u043c\u0435\u043d\u043b\u0438\u0432\u0430, \u043a\u043e\u044f\u0442\u043e \u0434\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0430 \u043a\u043e\u0438 \u0434\u0430\u043d\u043d\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u043d\u0430 \u043a\u043e\u0439 \u043a\u043e\u043d\u0442\u0430\u043a\u0442. \u041c\u043e\u0436\u0435\u043c \u0434\u0430 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043c \u0442\u043e\u0432\u0430, \u043a\u0430\u0442\u043e \u043e\u0442\u0431\u0435\u043b\u0435\u0436\u0438\u043c, \u0447\u0435 \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u0437\u0430 \u0432\u0441\u0435\u043a\u0438 \u043d\u043e\u0432 \u043a\u043e\u043d\u0442\u0430\u043a\u0442 \u0437\u0430\u043f\u043e\u0447\u0432\u0430\u0442 \u0441 \u0438\u043c\u0435 (\"name\"), \u0442\u0430\u043a\u0430 \u0447\u0435 \u043c\u043e\u0436\u0435\u043c \u0434\u0430 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0438 \u0434\u0430 \u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0430\u0432\u0430\u043c\u0435 \u0441 \u0435\u0434\u043d\u043e \u0432\u0441\u0435\u043a\u0438 \u043f\u044a\u0442, \u043a\u043e\u0433\u0430\u0442\u043e \u0432 \u043a\u043e\u043b\u043e\u043d\u0430\u0442\u0430 field \u0441\u0435 \u0441\u0440\u0435\u0449\u0430 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0442\u0430 \"name\":<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">contacts % \n  mutate(\n    person_id = cumsum(field == \"name\")\n  )\ncontacts<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 6 x 3\n#&gt;   field   value            person_id\n#&gt;   &lt;chr&gt;   &lt;chr&gt;                &lt;int&gt;\n#&gt; 1 name    Jiena McLellan           1\n#&gt; 2 company Toyota                   1\n#&gt; 3 name    John Smith               2\n#&gt; 4 company google                   2\n#&gt; 5 email   john@google.com          2\n#&gt; 6 name    Huxley Ratcliffe         3<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u0435\u0433\u0430, \u043a\u043e\u0433\u0430\u0442\u043e \u0438\u043c\u0430\u043c\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430 \u0432\u0441\u0435\u043a\u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442, \u043c\u043e\u0436\u0435\u043c \u0434\u0430 \u043e\u0431\u044a\u0440\u043d\u0435\u043c \u043f\u043e\u043b\u0435\u0442\u043e \u0438 \u0441\u0442\u043e\u0439\u043d\u043e\u0441\u0442\u0442\u0430 \u0432 \u043a\u043e\u043b\u043e\u043d\u0438:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">contacts %&gt;% \n  pivot_wider(names_from = field, values_from = value)<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"plaintext\">#&gt; # A tibble: 3 x 4\n#&gt;   person_id name             company email          \n#&gt;       &lt;int&gt; &lt;chr&gt;            &lt;chr&gt;   &lt;chr&gt;          \n#&gt; 1         1 Jiena McLellan   Toyota  &lt;NA&gt;           \n#&gt; 2         2 John Smith       google  john@google.com\n#&gt; 3         3 Huxley Ratcliffe &lt;NA&gt;    &lt;NA&gt;<\/code><\/pre>\n<p><\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p><\/p>\n<p>\u041b\u0438\u0447\u043d\u043e \u0430\u0437 \u0441\u043c\u044f\u0442\u0430\u043c, \u0447\u0435 \u043d\u043e\u0432\u0430\u0442\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f <strong>tidyr<\/strong> \u043d\u0430\u0438\u0441\u0442\u0438\u043d\u0430 \u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e-\u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0430 \u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u043d\u043e \u043f\u0440\u0435\u0432\u044a\u0437\u0445\u043e\u0436\u0434\u0430 \u043e\u0441\u0442\u0430\u0440\u0435\u043b\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <code>spread()<\/code> \u0438 <code>gather()<\/code>\u041d\u0430\u0434\u044f\u0432\u0430\u043c \u0441\u0435, \u0447\u0435 \u0442\u0430\u0437\u0438 \u0441\u0442\u0430\u0442\u0438\u044f \u0432\u0438 \u0435 \u043f\u043e\u043c\u043e\u0433\u043d\u0430\u043b\u0430 \u0434\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u0442\u0435 <code>pivot_longer()<\/code> \u0438 <code>pivot_wider()<\/code>.<\/p>\n<p>\u0418\u0437\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/444622\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0430\u043a\u0435\u0442 tidyr \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u044f\u0434\u0440\u043e \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R \u2014 tidyverse. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u2014 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443. \u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u0432\u044f\u0449\u0451\u043d\u043d\u0430\u044f \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0430\u043a\u0435\u0442\u0443, \u043d\u043e \u0434\u0430\u0442\u0438\u0440\u0443\u044e\u0435\u0442\u0441\u044f \u043e\u043d\u0430 2015 \u0433\u043e\u0434\u043e\u043c. \u0410 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u043d\u0430\u0437\u0430\u0434 \u0441\u043e\u043e\u0431\u0449\u0438\u043b \u0435\u0433\u043e \u0430\u0432\u0442\u043e\u0440 \u0425\u0435\u0434\u043b\u0438 \u0412\u0438\u043a\u0445\u0435\u043c. [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":76292,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-76291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0430\u043a\u0435\u0442 tidyr \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u044f\u0434\u0440\u043e \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R \u2014 tidyverse. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u2014 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443. \u041d\u0430 \u0425\u0430\u0431\u0440\u0435.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"bg_BG\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47R \u043f\u0430\u043a\u0435\u0442 tidyr \u0438 \u0435\u0433\u043e \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0430\u043a\u0435\u0442 tidyr \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u044f\u0434\u0440\u043e \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R \u2014 tidyverse. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u2014 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443. \u041d\u0430 \u0425\u0430\u0431\u0440\u0435.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-04-01T11:42:28+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-04-01T11:42:28+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47R \u043f\u0430\u043a\u0435\u0442 tidyr \u0438 \u043d\u043e\u0432\u0438\u0442\u0435 \u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider | ProHoster","description":"\u041f\u0430\u043a\u0435\u0442\u044a\u0442 tidyr \u0435 \u0447\u0430\u0441\u0442 \u043e\u0442 \u044f\u0434\u0440\u043e\u0442\u043e \u043d\u0430 \u0435\u0434\u043d\u0430 \u043e\u0442 \u043d\u0430\u0439-\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0438\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0435\u0437\u0438\u043a\u0430 R \u2014 tidyverse. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0442\u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u0438\u0442\u0435 \u0432 \u043f\u043e\u0434\u0440\u0435\u0434\u0435\u043d \u0432\u0438\u0434. \u041d\u0430 \u0425\u0430\u0431\u0440\u0430.","canonical_url":"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"bg_BG","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47R \u043f\u0430\u043a\u0435\u0442 tidyr \u0438 \u0435\u0433\u043e \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pivot_longer \u0438 pivot_wider | ProHoster","og:description":"\u041f\u0430\u043a\u0435\u0442 tidyr \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u044f\u0434\u0440\u043e \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R \u2014 tidyverse. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u2014 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443. \u041d\u0430 \u0425\u0430\u0431\u0440\u0435.","og:url":"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/r-paket-tidyr-i-ego-novye-funkczii-pivot_longer-i-pivot_wider","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-04-01T11:42:28+00:00","article:modified_time":"2020-04-01T11:42:28+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"76291","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 17:39:23","updated":"2022-09-28 03:21:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/posts\/76291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/comments?post=76291"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/posts\/76291\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/media\/76292"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/media?parent=76291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/categories?post=76291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/tags?post=76291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}