To check if a variable is greater than a value and add it to a vector in R, you can use a conditional statement and the append()
function.
Suppose you have a variable x
and a vector my_vector
, and you want to add x
to my_vector
if it's greater than or equal to a value y
. Here's an example code:
main.r92 chars8 lines
In this code, the if
statement checks if x
is greater than or equal to y
. If it's true, the append()
function adds x
to the end of my_vector
.
After running this code, my_vector
will be updated to include x
:
main.r25 chars3 lines
gistlibby LogSnag