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

upset gives error when data argument have tibble class #71

Open
jbkunst opened this issue Apr 6, 2017 · 1 comment
Open

upset gives error when data argument have tibble class #71

jbkunst opened this issue Apr 6, 2017 · 1 comment

Comments

@jbkunst
Copy link

jbkunst commented Apr 6, 2017

Hi @ngehlenborg @JakeConway

Thanks for this R implementation :D. I come up with an error when the I use data_frames instead of data.frames.

I'm open the issue because I didn't see something like this in the rest of issues.

library(tibble)
library(UpSetR)

set.seed(1)
df <- data_frame(x = sample(c(0, 1), size = 10, replace = TRUE), y = sample(c(0, 
  1), size = 10, replace = TRUE), z = sample(c(0, 1), size = 10, replace = TRUE))
df
#> # A tibble: 10 × 3
#>        x     y     z
#>    <dbl> <dbl> <dbl>
#> 1      0     0     1
#> 2      0     0     0
#> 3      1     1     1
#> 4      1     0     0
#> 5      0     1     0
#> 6      1     0     0
#> 7      1     1     0
#> 8      1     1     0
#> 9      1     0     1
#> 10     0     1     0


upset(df)
#> Error in sort.list(y): 'x' must be atomic for 'sort.list'
#> Have you called 'sort' on a list?

class(df)
#> [1] "tbl_df"     "tbl"        "data.frame"

df <- as.data.frame(df)
class(df)
#> [1] "data.frame"
upset(df)
#> Error: `breaks` and `labels` must have the same length

Then I noticed that the other problem is the length of the names on the data.

names(df) <- paste0(names(df), seq(1, ncol(df)))
df
#>    x1 y2 z3
#> 1   0  0  1
#> 2   0  0  0
#> 3   1  1  1
#> 4   1  0  0
#> 5   0  1  0
#> 6   1  0  0
#> 7   1  1  0
#> 8   1  1  0
#> 9   1  0  1
#> 10  0  1  0

upset(df) # works! :D

Hope this help to the package to have a better behavior ;).

devtools::session_info()
#> Session info --------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.3.3 (2017-03-06)
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  Spanish_Chile.1252          
#>  tz       America/Santiago            
#>  date     2017-04-06
#> Packages ------------------------------------------------------------------
#>  package    * version    date       source                            
#>  backports    1.0.5      2017-01-18 CRAN (R 3.3.2)                    
#>  colorspace   1.3-2      2016-12-14 CRAN (R 3.3.2)                    
#>  devtools     1.12.0     2016-06-24 CRAN (R 3.3.3)                    
#>  digest       0.6.12     2017-01-27 CRAN (R 3.3.3)                    
#>  evaluate     0.10       2016-10-11 CRAN (R 3.3.2)                    
#>  formatR      1.4        2016-05-09 CRAN (R 3.3.3)                    
#>  ggplot2      2.2.1.9000 2017-04-04 Github (tidyverse/ggplot2@f4398b6)
#>  gridExtra    2.2.1      2016-02-29 CRAN (R 3.3.3)                    
#>  gtable       0.2.0      2016-02-26 CRAN (R 3.3.3)                    
#>  htmltools    0.3.5      2016-03-21 CRAN (R 3.3.3)                    
#>  knitr        1.15.1     2016-11-22 CRAN (R 3.3.3)                    
#>  labeling     0.3        2014-08-23 CRAN (R 3.3.2)                    
#>  lazyeval     0.2.0      2016-06-12 CRAN (R 3.3.3)                    
#>  magrittr     1.5        2014-11-22 CRAN (R 3.3.3)                    
#>  memoise      1.0.0      2016-01-29 CRAN (R 3.3.3)                    
#>  munsell      0.4.3      2016-02-13 CRAN (R 3.3.3)                    
#>  plyr         1.8.4      2016-06-08 CRAN (R 3.3.3)                    
#>  Rcpp         0.12.9     2017-01-14 CRAN (R 3.3.2)                    
#>  rmarkdown    1.4        2017-03-24 CRAN (R 3.3.3)                    
#>  rprojroot    1.2        2017-04-03 Github (krlmlr/rprojroot@6d1069c) 
#>  scales       0.4.1      2016-11-09 CRAN (R 3.3.3)                    
#>  stringi      1.1.3      2017-03-21 CRAN (R 3.3.3)                    
#>  stringr      1.2.0      2017-02-18 CRAN (R 3.3.3)                    
#>  tibble     * 1.3.0      2017-04-01 CRAN (R 3.3.3)                    
#>  UpSetR     * 1.3.3      2017-03-21 CRAN (R 3.3.3)                    
#>  withr        1.0.2      2016-06-20 CRAN (R 3.3.3)                    
#>  yaml         2.1.14     2016-11-12 CRAN (R 3.3.2)
@achamess
Copy link

achamess commented May 5, 2018

Just to add to this, I was getting the same error. I didn't realize the problem was that my df was being read as a tibble, since I had tidyverse loaded. The workaround is to use upset(as.data.frame(data) when making the call.

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

2 participants