Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

collate="rows" strips factors to ints #3

Open
kleinschmidt opened this issue Sep 5, 2017 · 0 comments
Open

collate="rows" strips factors to ints #3

kleinschmidt opened this issue Sep 5, 2017 · 0 comments

Comments

@kleinschmidt
Copy link

For the by_* functions, any factor columns in a data frame returned by the function to be applied get converted to ints when collating by rows:

library(purrr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(purrrlyr)
library(magrittr)
#> 
#> Attaching package: 'magrittr'
#> The following object is masked from 'package:purrr':
#> 
#>     set_names

data_frame(a = factor(c("a", "b"))) %>% 
  by_row(~ .x, .collate="rows")
#> # tibble [2 x 3]
#>        a  .row     a
#>   <fctr> <int> <int>
#> 1      a     1     1
#> 2      b     2     2

data_frame(a = factor(c("a", "b"))) %>% 
  by_row(~ .x, .collate="list", .lables=FALSE) %>%
  pull(.out) %>%
  lift(bind_rows)()
#> # A tibble: 2 x 1
#>        a
#>   <fctr>
#> 1      a
#> 2      b

devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.1 (2017-06-30)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       US/Eastern                  
#>  date     2017-09-05
#> Packages -----------------------------------------------------------------
#>  package    * version date       source        
#>  assertthat   0.2.0   2017-04-11 CRAN (R 3.4.1)
#>  backports    1.1.0   2017-05-22 CRAN (R 3.4.1)
#>  base       * 3.4.1   2017-06-30 local         
#>  bindr        0.1     2016-11-13 CRAN (R 3.4.1)
#>  bindrcpp     0.2     2017-06-17 CRAN (R 3.4.1)
#>  compiler     3.4.1   2017-06-30 local         
#>  datasets   * 3.4.1   2017-06-30 local         
#>  devtools     1.13.3  2017-08-02 CRAN (R 3.4.1)
#>  digest       0.6.12  2017-01-27 CRAN (R 3.4.1)
#>  dplyr      * 0.7.2   2017-07-20 CRAN (R 3.4.1)
#>  evaluate     0.10.1  2017-06-24 CRAN (R 3.4.1)
#>  glue         1.1.1   2017-06-21 CRAN (R 3.4.1)
#>  graphics   * 3.4.1   2017-06-30 local         
#>  grDevices  * 3.4.1   2017-06-30 local         
#>  htmltools    0.3.6   2017-04-28 CRAN (R 3.4.1)
#>  knitr        1.17    2017-08-10 CRAN (R 3.4.1)
#>  magrittr   * 1.5     2014-11-22 CRAN (R 3.4.1)
#>  memoise      1.1.0   2017-04-21 CRAN (R 3.4.1)
#>  methods    * 3.4.1   2017-06-30 local         
#>  pkgconfig    2.0.1   2017-03-21 CRAN (R 3.4.1)
#>  purrr      * 0.2.3   2017-08-02 CRAN (R 3.4.1)
#>  purrrlyr   * 0.0.2   2017-05-13 CRAN (R 3.4.1)
#>  R6           2.2.2   2017-06-17 CRAN (R 3.4.1)
#>  Rcpp         0.12.12 2017-07-15 CRAN (R 3.4.1)
#>  rlang        0.1.2   2017-08-09 CRAN (R 3.4.1)
#>  rmarkdown    1.6     2017-06-15 CRAN (R 3.4.1)
#>  rprojroot    1.2     2017-01-16 CRAN (R 3.4.1)
#>  stats      * 3.4.1   2017-06-30 local         
#>  stringi      1.1.5   2017-04-07 CRAN (R 3.4.1)
#>  stringr      1.2.0   2017-02-18 CRAN (R 3.4.1)
#>  tibble       1.3.4   2017-08-22 CRAN (R 3.4.1)
#>  tools        3.4.1   2017-06-30 local         
#>  utils      * 3.4.1   2017-06-30 local         
#>  withr        2.0.0   2017-07-28 CRAN (R 3.4.1)
#>  yaml         2.1.14  2016-11-12 CRAN (R 3.4.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant