if/else test if ANY row in a column is greater than an absolute value (R studio)

Viewed 24

I'm trying to test if any value/row from the column cooksd is greater than absolute 1.

if (any(lev$cooksd) > abs(-1)) {
  print('yey')
} else {
  print('no') 
}

Warning message:

In any(lev$cooksd) : coercing argument of type 'double' to logical

but I don't think the any() function is doing the job...Any thoughts on this?

Thanks in advance!

Obs:

the data looks like this: (first two rows)

cooksd mdffits covtrace covratio leverage.o~1
 <dbl>   <dbl>    <dbl>    <dbl>        <dbl>
 0.0496  0.0478    0.0368     1.04        0.395
 0.0261  0.0251    0.0371     1.04        0.395

edited after comment:

if (any(abs(lev$cooksd) > 1)) {
  print('yey')
} else {
  print('no') 
}
0 Answers
Related