You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thank you for the fix to #6480. it mostly works great, but has introduced a weird scenario, where the result thinks its an xts object, but is not a matrix. as xts is an indexed matrix, this should never happen, and the result is now breaking subsequent code. this issue really applies to all zoo objects, not just xts
if fcase kept the ouput as a 1 column matrix, matching what was passed in, this works would be fine (suspect this may break other code)
if fcase returned a vector stripping the class and attributes, this would also be usable
returning this hybrid output (non matrix xts) is problematic
i guess, for me, it comes down to what is the design contract for fcase?
if it is to return what was passed in, it should probably not be converting 1 column matrix to a vector
if it is to return a vector, maybe calling as.vector on inputs would be safer as it would allow dispatching to handle things properly
thank you for the fix to #6480. it mostly works great, but has introduced a weird scenario, where the result thinks its an
xts
object, but is not a matrix. as xts is an indexed matrix, this should never happen, and the result is now breaking subsequent code. this issue really applies to allzoo
objects, not justxts
if fcase kept the ouput as a 1 column matrix, matching what was passed in, this works would be fine (suspect this may break other code)
if fcase returned a vector stripping the class and attributes, this would also be usable
returning this hybrid output (non matrix xts) is problematic
cc @joshuaulrich
MRE:
library(xts)
d <- xts(matrix(runif(4000, 0, 100), ncol = 4), order.by = Sys.Date() + (1:1000))
r <- data.table::fcase(d[,1] > d[,4], d[,2], default = (d[,2] + d[,3]) / 2)
class(r)
#[1] "xts" "zoo"
is.matrix(r)
#[1] FALSE
#data.table_1.16.2
The text was updated successfully, but these errors were encountered: