socialresearchcentre / projectable

Produce table-like objects made up of special metadata-rich column vectors, and project them into two dimensions.
https://socialresearchcentre.github.io/projectable
GNU General Public License v3.0
3 stars 0 forks source link

Error thrown if row expression matches no records in data #19

Closed kinto-b closed 3 years ago

kinto-b commented 3 years ago
library(dplyr)
library(projectable)
mtcars %>% 
  prj_tbl_rows(big = mpg > 40, small = mpg < 40) %>% 
  prj_tbl_cols(four_cyl = col_freq(cyl %in% 4, !cyl %in% NA)) %>% 
  prj_tbl_summarise()
#> Error in cyl %in% 4: object 'cyl' not found

Created on 2021-03-29 by the reprex package (v1.0.0)

Issue arises here:

https://github.com/socialresearchcentre/projectable/blob/aebf1664aede18564eb9352e156419b136669471/R/prj_tbl.R#L113-L125

The fix is to check whether .data is NULL before evaluating