Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfoverlaps error message could be more informative #3007
Comments
|
Adding the following input checks seems to do the job, so I guess it might just be a matter of whether the overhead performance hit is acceptable. File diff here between fork branch msummersgill/data.table/foverlaps-NA-eror and Rdatatable/data.table/master reflects where they might fit into the rest of the input checks. if ( anyNA(x[[xintervals[1L]]]) )
stop("NA values in data.table 'x' start column: '", xintervals[1L],"'. All rows with NA values in the range columns must be removed for foverlaps() to work")
if ( anyNA(x[[xintervals[2L]]]) )
stop("NA values in data.table 'x' end column: '", xintervals[2L],"'. All rows with NA values in the range columns must be removed for foverlaps() to work")
if ( anyNA(y[[yintervals[1L]]]) )
stop("NA values in data.table 'y' start column: '", yintervals[1L],"'. All rows with NA values in the range columns must be removed for foverlaps() to work")
if ( anyNA(y[[yintervals[2L]]]) )
stop("NA values in data.table 'y' end column: '", yintervals[2L],"'. All rows with NA values in the range columns must be removed for foverlaps() to work") With the added checks, the same example above runs as follows: foverlaps(DT_x,DT_y)
# Error in foverlaps(DT_x, DT_y) :
# NA values in data.table 'x' end column: 'x2'. All rows with NA values in the range columns must be removed for foverlaps() to work |
|
maybe check could be added on C level after overlapping join has finished, then it should not add overhead. |
I came across a valid error when using
foverlaps(), and I was able to figure out the solution pretty quickly by googling the error message and finding this Stack Overflow question: Foverlaps error: Error in if (any(x[[xintervals[2L]]] - x[[xintervals[1L]]] < 0L)) stopIt seems like an error message along the line of
Error in foverlaps: NA values in x table interval column; all rows with NA values in the range columns must be removed for foverlaps to workmight be helpful to users and get them pointed in the right direction without a trip to Stack Overflow.Skimming foverlaps.R it looks like this might require an extra step in
foverlaps()to check forNAvalues before executing -- if that is the case then I'm not sure the added overhead in the function call would be worth it or not, but if the message could be changed without slowing down the function call this could be an improvement.Thoughts on feasibility/value?
sessionInfo()output: