r - 2 conditions for creating a boolean vector -
i have 2 vectors , single number.
a <- rnorm(40,10,4) d <- rep(0,length(a) filling_limit <- 8
now, want 40*1 boolean vector (has.room
) giving me info if 2 conditions satisfied:
has.room <- > 0 && d < filling_limit
instead of returning vector 40 times true
single true
. what's reason this? if wondering 0 vector: thing part of loop , d
change within time. thanks!
has.room <- > 0 & d < filling_limit
from page logical operators: &
, &&
indicate logical , and |
, ||
indicate logical or. the shorter form performs elementwise comparisons in same way arithmetic operators. longer form evaluates left right examining first element of each vector. evaluation proceeds until result determined.
Comments
Post a Comment