Closed Bisaloo closed 1 year ago
MRE:
library(distributional)
x <- y <- dist_normal()
quantile(x, c(0.05, 0.95))
#> [[1]]
#> [1] -1.644854 1.644854
dimnames(y) <- "response"
quantile(y, c(0.05, 0.95))
#> Error in FUN(X[[i]], ...): attempt to set 'colnames' on an object with less than two dimensions
Created on 2022-09-02 by the reprex package (v2.0.1)
Fixed, thanks!
library(distributional)
x <- y <- dist_normal()
quantile(x, c(0.05, 0.95))
#> [[1]]
#> [1] -1.644854 1.644854
dimnames(y) <- "response"
quantile(y, c(0.05, 0.95))
#> [[1]]
#> [1] -1.644854 1.644854
x <- y <- dist_multivariate_normal(mu = list(c(1,2)),
sigma = list(matrix(c(4,2,2,3), ncol=2)))
quantile(x, c(0.05, 0.95))
#> [[1]]
#> [,1] [,2]
#> [1,] -2.289707 -0.8489701
#> [2,] 4.289707 4.8489701
dimnames(y) <- c("a", "b")
quantile(y, c(0.05, 0.95))
#> [[1]]
#> a b
#> [1,] -2.289707 -0.8489701
#> [2,] 4.289707 4.8489701
Created on 2022-09-02 by the reprex package (v2.0.1)
quantile()
fails when trying to get quantiles from afbl_ts
column withdistribution
s. I was initially thinking it was affecting all tibbles but it seems restricted tofbl_ts
, as shown in the reprex below where it's working fortibble
andtsibble
Created on 2022-05-25 by the reprex package (v2.0.1.9000)
The issue comes from
https://github.com/mitchelloharawild/distributional/blob/d04d5284b176b3ee72df3a6eb3a8fa996388d7e3/R/utils.R#L59
As shown in the 2nd reprex below,
fbl_ts
keep a dimname even after beingpull
ed, which throwsdist_apply()
off:Created on 2022-05-25 by the reprex package (v2.0.1.9000)
Therefore, commenting
https://github.com/mitchelloharawild/distributional/blob/d04d5284b176b3ee72df3a6eb3a8fa996388d7e3/R/utils.R#L59
solves this specific issue but it probably causes problems elsewhere.