[R] function to compare lengths of objects?

Spencer Graves spencer.graves at structuremonitoring.com
Mon May 5 07:02:07 CEST 2014


       Is there a standard function to generate messages like "longer 
object length is not a multiple of shorter object length" but providing 
more information like the names of the objects?


       For example, "a/b" issues, "Warning message:  In a/b : longer 
object length is not a multiple of shorter object length" if the length 
of one is not a multiple of the other.  I want a utility to produce 
messages that include the lengths of "a" and "b" and other information.


       If you were to write such a function, what would you include in 
it?  Arguments?  Values?  Options?


       I started creating "compareLengths.Rd" with 
\usage{compareLengths(x, y, name.x=NULL, name.y=NULL, Source='', 
compFun=c('length', 'NROW'), action=c(comparable='', 
incomparable='warning'), maxChar=20, ...)} and \value{A character vector 
of length 2.  The first element is either 'equal', 'compatible' or 
'incompatible'.  The second element is the message composed for the 
desired "action".


       Thanks,
       Spencer Graves



More information about the R-help mailing list