Наименование столбца подсчета dplyr - PullRequest
0 голосов
/ 29 января 2019

Согласно https://dplyr.tidyverse.org/reference/tally.html, работает следующий код:

# Change the name of the newly created column:
species <-
 starwars %>%
 count(species, homeworld, sort = TRUE, name = "n_species_by_homeworld")
species

Должно выдать:

#> # A tibble: 58 x 3
#>    species homeworld n_species_by_homeworld
#>    <chr>   <chr>                      <int>
#>  1 Human   Tatooine                       8
#>  2 Human   <NA>                           5
#>  3 Human   Naboo                          5
#>  4 Gungan  Naboo                          3
#>  5 Human   Alderaan                       3
#>  6 <NA>    <NA>                           2
#>  7 <NA>    Naboo                          2
#>  8 Droid   <NA>                           2
#>  9 Droid   Tatooine                       2
#> 10 Human   Corellia                       2
#> # … with 48 more rows

Однако я получаю:

# A tibble: 58 x 4
   species  homeworld name                       n
   <chr>    <chr>     <chr>                  <int>
 1 Human    Tatooine  n_species_by_homeworld     8
 2 Human    Naboo     n_species_by_homeworld     5
 3 Human    NA        n_species_by_homeworld     5
 4 Gungan   Naboo     n_species_by_homeworld     3
 5 Human    Alderaan  n_species_by_homeworld     3
 6 Droid    Tatooine  n_species_by_homeworld     2
 7 Droid    NA        n_species_by_homeworld     2
 8 Human    Corellia  n_species_by_homeworld     2
 9 Human    Coruscant n_species_by_homeworld     2
10 Kaminoan Kamino    n_species_by_homeworld     2
# ... with 48 more rows

Справка?

Я бегу:

  • R версии 3.5.0 (2018-04-23)

  • Платформа: i386-w64-mingw32 / i386 (32-разрядная версия)

  • Под управлением: Windows> = 8 x64 (сборка 9200)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...