Skip to content

About warnings for non-matched items

2 messages · ling ling, Richard Cotton

#
The error means that the input you provided to the max function is missing 
or NULL or of length 0.  At a guess, what has happened is that you've 
called grep, which didn't match anything (and so returned integer(0)), 
then used that as an input to max.

To get rid of the warning, check the input to max first.  e.g.

x1 <- c("foo", "bar", "foo")
g1 <- grep("foo", x1)
if(length(g1)) max(g1)

g2 <- grep("baz", x1)
if(length(g2)) max(g1)

Regards,
Richie.

Mathematical Sciences Unit
HSL



------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}