RobinHankin / frab

1 stars 0 forks source link

x[is.na(x)] fails if empty #14

Closed RobinHankin closed 10 months ago

RobinHankin commented 1 year ago
suppressMessages(library("frab"))
(x <- frab(c(x=5,y=1,z=2)))
#> A frab object with entries
#> x y z 
#> 5 1 2
x["y"] <- NA
x[is.na(x)]
#> A frab object with entries
#>  y 
#> NA
x[is.na(x)] <- 33
x[is.na(x)]
#> Error in .local(x, i, j = j, ..., drop): not implemented

Above, the first call to x[is.na(x)] works fine, extracting element y. But the second fails.

RobinHankin commented 1 year ago

Probably worth noting here that there is such a thing as an empty named vector

x <- 1:3
y <- setNames(1:3,letters[1:3])
x[x>4]
#> integer(0)
(z <- y[y>4])
#> named integer(0)

Also worth reminding myself that existing frab functionality can deal with this:

suppressMessages(library("frab"))
y <- setNames(1:3,letters[1:3])
z <- y[y>4]
frab(z)
#> The empty frab object
RobinHankin commented 10 months ago

fixed in 9c5f992