r - Count function error (wrong result size) -
i having weird problem using count
function introduced today. when type:
a <- count(data, c("col1", "col2")
error popping up
error: wrong result size
earlier code working fine. appreciated.
e.g data <- matrix((1,2,1,2,1,3,1,3,2,3,2,4,2,3,2,5), nrow=8, ncol=2)
most default dplyr
functions made use data.frame
column names unquoted (non-standard evaluation). hadley builds in standard eval versions, well, have same name, underscore (_
) @ end: in case, count_()
. standard eval ones can use quoted values arranged yours above:
count_(mtcars, c('cyl', 'gear'))
really, standard-eval versions overkill unless need pass variable stores name, though. in case, normal non-standard eval version work neatly, , produce same thing, while saving typing few quotes:
count(mtcars, cyl, gear)
either way, get
source: local data frame [8 x 3] groups: cyl [?] cyl gear n (dbl) (dbl) (int) 1 4 3 1 2 4 4 8 3 4 5 2 4 6 3 2 5 6 4 4 6 6 5 1 7 8 3 12 8 8 5 2
for more detail, see above link, though goes way more specifics need now.
Comments
Post a Comment