UpSetR icon indicating copy to clipboard operation
UpSetR copied to clipboard

Column names with leading digit throw error

Open dariober opened this issue 6 years ago • 6 comments

Hi- Thanks for the great tool!

It seems that column names starting with a digit don't play well with the intersections option.

This is ok:

movies <- read.csv( system.file("extdata", "movies.csv", package = "UpSetR"), header=TRUE, sep=";" )
upset(movies, intersections= list(list('Action', 'Comedy')))

Change Action to 1Action:

names(movies)[which(names(movies) == 'Action')] <- '1Action'
names(movies)
 [1] "Name"        "ReleaseDate" "1Action"  ...

upset(movies, intersections= list(list('1Action', 'Comedy')))
Error in `[.data.frame`(x, temp_sets) : undefined columns selected

This is with:

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /export/projects/III-data/wcmp_bioinformatics/db291g/miniconda3/envs/20190705_scott_hda1/lib/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] UpSetR_1.4.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       assertthat_0.2.1 crayon_1.3.4     dplyr_0.8.3      grid_3.5.1       plyr_1.8.4       R6_2.4.0         gtable_0.3.0     magrittr_1.5     scales_1.0.0     ggplot2_3.1.0    pillar_1.4.2     rlang_0.4.0      lazyeval_0.2.2   labeling_0.3    
[16] glue_1.3.1       purrr_0.3.2      munsell_0.5.0    compiler_3.5.1   pkgconfig_2.0.2  colorspace_1.4-1 tidyselect_0.2.5 gridExtra_2.3    tibble_2.1.3

dariober avatar Jul 11 '19 10:07 dariober

Have you tried wrapping 1Action in backticks: `1Action`, as you can with other 'illegal' names in R like names with spaces etc.? It would be good to detect these and wrap these automatically through, the way a lot of the tidyverse packages seem to.

RichardJActon avatar Jul 11 '19 22:07 RichardJActon

Hi- Thanks for replying. I'm not sure I understand your suggestion but this doesn't work either:

upset(movies, intersections= list(list(`1Action`, 'Comedy')))
Error in upset(movies, intersections = list(list(`1Action`, "Comedy"))) : 
  object '1Action' not found

dariober avatar Jul 12 '19 09:07 dariober

I have the same issue and confirm backticks do not work for solving the issue.

list("30DC38E5.var")

results in

Error in [.data.frame(data, sets) : undefined columns selectedError in [.data.frame`(data, sets) : undefined columns selected

ghost avatar Jul 15 '19 18:07 ghost

Same error occurs when there is a space or a hyphen in the set name

christianholland avatar Nov 20 '19 12:11 christianholland

@christianholland Same error here due to spaces in the set names, solved, thanks!

maluque avatar Mar 23 '22 09:03 maluque

Similar issue occurs when there are + or - in the set names.

dy-lin avatar Aug 16 '22 00:08 dy-lin