{"id":388109,"date":"2024-06-29T07:44:21","date_gmt":"2024-06-29T07:44:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=388109"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=388109","title":{"rendered":"<span>\u041e \u0431\u0435\u0434\u043d\u043e\u043c \u0431\u0438\u0442\u0435 \u0437\u0430\u043c\u043e\u043b\u0432\u0438\u0442\u0435 \u0441\u043b\u043e\u0432\u043e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/59\/df\/0e\/59df0ee714472500917843.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/59\/df\/0e\/59df0ee714472500917843.jpeg\" data-blurred=\"true\"\/><br \/>  <em>\u041d. \u041a\u043e\u0431\u0440\u0438\u043d\u0441\u043a\u0438\u0439, \u0412. \u041f\u0435\u043a\u0435\u043b\u0438\u0441 \u00ab\u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u043c\u044b\u0441\u043b\u0438\u00bb \u2014 \u041c\u043e\u043b\u043e\u0434\u0430\u044f \u0433\u0432\u0430\u0440\u0434\u0438\u044f, 1959<\/em><\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0432\u043e\u043a\u0440\u0443\u0433 \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0442 \u0413\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u041f\u0435\u0442\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u0417\u0435\u0442\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0438 \u0442.\u0434., \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0433\u043e\u0440\u0434\u044f\u0442\u0441\u044f \u0441\u0432\u043e\u0435\u0439 \u0411\u0438\u0433\u0414\u0430\u0442\u043e\u0439, \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043e \u0431\u0438\u0442\u0430\u0445 \u0432 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u043c \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043c\u043e\u0432\u0435\u0442\u043e\u043d. \u041e\u0434\u043d\u0430\u043a\u043e \u0438 \u0431\u0438\u0442\u044b \u0438\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b. \u0422\u0435\u043c\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u0430 \u043e\u0434\u043d\u0430 \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u043a\u0430, \u043b\u0435\u0436\u0430\u0449\u0430\u044f \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/habrahabr.ru\/users\/i_shutov\/posts\/\" rel=\"nofollow noopener noreferrer\">\u0441\u0435\u0440\u0438\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439<\/a>. <a name=\"habracut\"><\/a><\/p>\n<p>  <\/p>\n<h1 id=\"postanovka-zadachi\">\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h1>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 X \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0435\u0431\u0440\u0435\u043d\u0434\u0438\u043d\u0433. \u041f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u043b\u0438 \u0434\u043e\u0440\u043e\u0433\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0441\u043f\u0435\u0446\u043e\u0432, \u043e\u043d\u0438 \u0432\u044b\u043a\u0430\u0442\u0438\u043b\u0438 \u043d\u0430 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043d\u0438\u0435 6 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043b\u043e\u0433\u043e\u0442\u0438\u043f\u043e\u0432. \u0422\u0443\u0442 \u0438 \u00ab\u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f I\u00bb \u0438 \u00ab\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e\u0433\u0440\u0430\u043d\u043d\u0430\u044f O\u00bb \u0438 \u00ab\u0433\u0438\u0431\u043a\u0430\u044f W\u00bb \u0438 \u00ab\u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u0433\u0440\u0430\u0444\u0438\u0442\u00bb \u0438 \u00ab\u0432\u0435\u0441\u0435\u043b\u044b\u0439 \u043b\u0430\u0439\u043c\u00bb&#8230;<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0440\u0430\u043b\u0438 \u0441 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043e\u0442\u0432\u0435\u0442\u044b, \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 [1; 6], \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u043c\u0441\u044f \u043b\u043e\u0433\u043e\u0442\u0438\u043f\u0430\u043c. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0447\u0435\u0442\u043a\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0414\u0440\u0443\u0433\u0438\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432\u0441\u0435 6. \u0422\u0440\u0435\u0442\u044c\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043c\u044b \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0430\u0434\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u043b\u043e\u0433\u043e\u0442\u0438\u043f.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">     uid      vote  1: id001     6,5,3  2: id002 5,3,4,2,1  3: id003   2,5,4,3  4: id004       1,4  5: id005   2,3,5,1  6: id006         3  7: id007       6,3  8: id008 2,5,6,4,3<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432. \u041d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0435 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f.<\/p>\n<p>  <\/p>\n<h1 id=\"variant-1\">\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1<\/h1>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u043f\u0443\u0441\u043a\u043d\u0438\u043a DS \u043a\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u043f\u043e\u0442\u043e\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0443\u0442\u0435\u043c pivot \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439, \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0417\u0430\u0441\u0430\u0434\u0430 \u0432 \u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">library(tidyverse)  # \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 df &lt;- tibble(   id = 1:3,   answer_1 = rep(1, 3),   answer_2 = rep(2, 3),   answer_3 = c(3, NA, NA),   answer_4 = c(4, NA, 4),   answer_5 = rep(5, 3),   answer_6 = rep(6, 3) )  df %>%   pivot_longer(-id, names_to = NULL, values_to = \"brand_id\") %>%   filter(!is.na(brand_id)) %>%   group_by(id) %>%   summarise(     recognized_brands = list(brand_id),     unrecognized_brands = map(recognized_brands, function(x) setdiff(x = 1:6, y= x))   ) %>%   unnest_longer(recognized_brands) %>%   unnest_longer(unrecognized_brands) %>%   pivot_longer(-id, names_to = \"type\", values_to = \"brand_id\") %>%   filter(!is.na(brand_id)) %>%   distinct() %>%   group_by(brand_id, type) %>%   summarise(N = n()) %>%   pivot_wider(names_from = type, values_from = N, values_fill = 0) %>%   mutate(brand_recognition = recognized_brands \/ (recognized_brands + unrecognized_brands))<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># A tibble: 6 x 4 # Groups:   brand_id [6]   brand_id recognized_brands unrecognized_brands brand_recognition      &lt;dbl>             &lt;int>               &lt;int>             &lt;dbl> 1        1                 3                   0             1     2        2                 3                   0             1     3        3                 1                   2             0.333 4        4                 2                   1             0.667 5        5                 3                   0             1     6        6                 3                   0             1    <\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d. \u0427\u0435\u0433\u043e \u0435\u0449\u0435 \u0445\u043e\u0442\u0435\u0442\u044c?<\/p>\n<p>  <\/p>\n<h1 id=\"variant-2\">\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2<\/h1>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0441 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0447\u0443\u0442\u044c \u043f\u0440\u043e\u0449\u0435. \u0421\u0432\u0430\u043b\u0438\u043c \u0432\u0441\u0435 \u0432 \u043a\u0443\u0447\u0443 \u0438 \u0432 \u043d\u0435\u0439 \u0436\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/s9\/n6\/uw\/s9n6uwjlde-9d8m6rk6xvyk03oi.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/s9\/n6\/uw\/s9n6uwjlde-9d8m6rk6xvyk03oi.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u044f\u043c\u043e \u0421\u043f\u043e\u0440\u0442\u043b\u043e\u0442\u043e \u043a\u0430\u043a\u043e\u0435-\u0442\u043e. \u041a\u0443\u0447\u0430 \u0448\u0430\u0440\u043e\u0432 \u0438 6 \u0446\u0438\u0444\u0440.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">library(tidyverse)  # \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 ============= df &lt;- tibble(uid = sprintf(\"id%03d\", 1:100)) %>%   rowwise() %>%   mutate(vote = list(sample(1:6, runif(1, 1, 6)))) %>%   ungroup()  # \u0440\u0430\u0441\u0447\u0435\u0442\u044b unlist(df$vote) %>%    janitor::tabyl()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"> .  n   percent  1 54 0.1703470  2 55 0.1735016  3 52 0.1640379  4 52 0.1640379  5 52 0.1640379  6 52 0.1640379<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"variant-3\">\u0412\u0430\u0440\u0438\u0430\u043d\u0442 3<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0436\u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0432 Excel. \u0422.\u0435. \u0432\u0441\u0435 \u044d\u0442\u0438 \u0446\u0438\u0444\u0435\u0440\u043a\u0438 1..6 \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u043f\u043e 6-\u0442\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c. \u0412\u0430\u0440\u0438\u0430\u043d\u0442 1 \u043c\u044b \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u043c \u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u0435 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0435\u0441\u0435\u043b\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e \u0431\u0438\u0442\u044b \u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B2%D0%BE%D0%B8%D1%87%D0%BD%D0%B0%D1%8F_%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_%D1%81%D1%87%D0%B8%D1%81%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F\" rel=\"nofollow noopener noreferrer\">\u0434\u0432\u043e\u0438\u0447\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/es\/tn\/tu\/estntusaf6d9zebd6z9_wt2pgj0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/es\/tn\/tu\/estntusaf6d9zebd6z9_wt2pgj0.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432? \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441 0 \u0438 1, \u0433\u0434\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u043e\u043c\u0435\u0440\u0443 \u043b\u043e\u0433\u043e\u0442\u0438\u043f\u0430, \u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u2014 \u043c\u043d\u0435\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430. \u0415\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u0431\u0438\u043d\u0430\u0440\u0435\u043d, \u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0432\u0441\u0435\u0433\u043e 6, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u043c\u043e\u0440\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438, \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u043e\u0432. \u0417\u0430 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u0430\u0448\u0438\u043d\u0430.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u043e\u043d\u0443\u0435\u043c \u0447\u0438\u0441\u043b\u0430, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044f 1 \u0432 \u0442\u0435\u0445 \u0431\u0438\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432. \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u0430\u043c. \u0414\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0443\u043c\u043c\u044b \u0441\u0442\u0435\u043f\u0435\u043d\u0435\u0439 \u0434\u0432\u043e\u0439\u043a\u0438 (\u0441\u043c. \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443). \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c AND \u043f\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0437\u0440\u044f\u0434\u0443, \u0441\u0434\u0432\u0438\u0433\u0443 \u0432\u043f\u0440\u0430\u0432\u043e \u0438\u043b\u0438 \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">library(tidyverse) library(bitops)  # \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 ============= df &lt;- tibble(uid = sprintf(\"id%03d\", 1:100)) %>%   rowwise() %>%   mutate(vote = list(sample(1:6, runif(1, 1, 6)))) %>%   ungroup()  # \u0440\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 ============= # \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0442\u043e\u0432\u0443\u044e \u043c\u0430\u0441\u043a\u0443 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 res_df &lt;- df %>%   rowwise() %>%   mutate(mask = sum(2^vote),           logo = matrix(            as.logical(bitAnd(mask, c(1, 2, 4, 8, 16, 32))),             nrow = 1)   ) %>%   ungroup()  # \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0443\u044e mm &lt;- res_df$logo * 1L  sum(mm) # \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c colMeans(mm) colSums(mm)<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0413\u0440\u0443\u0437\u0438\u0442\u044c \u0438 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0411\u043e\u043b\u044c\u0448\u0438\u0435 \u0414\u0430\u043d\u043d\u044b\u0435 \u2014 \u0432\u0430\u0436\u043d\u0430\u044f \u0438 \u043d\u0443\u0436\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0432\u0435\u0449\u0438, \u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0435\u0441\u0435\u043b\u0435\u0435 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u043d\u0435\u0435. \u0418 \u0438\u043d\u043e\u0433\u0434\u0430 \u0441\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u043e\u0431\u043b\u0430\u043a\u043e\u0432 \u0438 \u043f\u0435\u0442\u0430\u0431\u0430\u0439\u0442\u043e\u0432 \u0438 \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u2014 <a href=\"https:\/\/habr.com\/ru\/post\/592651\/\">\u00ab\u0417\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e REST API\u00bb<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/596399\/\"> https:\/\/habr.com\/ru\/articles\/596399\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/59\/df\/0e\/59df0ee714472500917843.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/59\/df\/0e\/59df0ee714472500917843.jpeg\" data-blurred=\"true\"\/><br \/>  <em>\u041d. \u041a\u043e\u0431\u0440\u0438\u043d\u0441\u043a\u0438\u0439, \u0412. \u041f\u0435\u043a\u0435\u043b\u0438\u0441 \u00ab\u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u043c\u044b\u0441\u043b\u0438\u00bb \u2014 \u041c\u043e\u043b\u043e\u0434\u0430\u044f \u0433\u0432\u0430\u0440\u0434\u0438\u044f, 1959<\/em><\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0432\u043e\u043a\u0440\u0443\u0433 \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0442 \u0413\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u041f\u0435\u0442\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u0417\u0435\u0442\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0438 \u0442.\u0434., \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0433\u043e\u0440\u0434\u044f\u0442\u0441\u044f \u0441\u0432\u043e\u0435\u0439 \u0411\u0438\u0433\u0414\u0430\u0442\u043e\u0439, \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043e \u0431\u0438\u0442\u0430\u0445 \u0432 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u043c \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043c\u043e\u0432\u0435\u0442\u043e\u043d. \u041e\u0434\u043d\u0430\u043a\u043e \u0438 \u0431\u0438\u0442\u044b \u0438\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b. \u0422\u0435\u043c\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u0430 \u043e\u0434\u043d\u0430 \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u043a\u0430, \u043b\u0435\u0436\u0430\u0449\u0430\u044f \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/habrahabr.ru\/users\/i_shutov\/posts\/\" rel=\"nofollow noopener noreferrer\">\u0441\u0435\u0440\u0438\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439<\/a>. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-388109","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=388109"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388109\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=388109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=388109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=388109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}