Skip to content

assert has error for single-row data frames and multiple columns #94

@jayqi

Description

@jayqi

assert errors when making an assertion on multiple columns for a single-row data frame.

My guess is that that the issue involves the internals somewhere incorrectly treating the row as a vector, rather than as multiple length-one vectors. assert works fine with one-row-one-column, or multiple-rows-multiple-columns

Reproducible example, asserting on two columns with a single-row data frame:

library(assertr)
library(magrittr)
head(mtcars, 1) %>% assert(not_na, am, vs)
#> Error in dimnames(x) <- dn: length of 'dimnames' [2] not equal to array extent
packageVersion("assertr")
#> [1] '2.7'

Note that this error does not occur when asserting about only a single column for a single-row data frame:

library(assertr)
library(magrittr)
head(mtcars, 1) %>% assert(not_na, am)
#>           mpg cyl disp  hp drat   wt  qsec vs am gear carb
#> Mazda RX4  21   6  160 110  3.9 2.62 16.46  0  1    4    4

or asserting about multiple columns with multiple-row data frames:

library(assertr)
library(magrittr)
head(mtcars, 2) %>% assert(not_na, am, vs)
#>               mpg cyl disp  hp drat    wt  qsec vs am gear carb
#> Mazda RX4      21   6  160 110  3.9 2.620 16.46  0  1    4    4
#> Mazda RX4 Wag  21   6  160 110  3.9 2.875 17.02  0  1    4    4

Created on 2020-03-05 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions