Syntax:
>samples <- c(rep(1:10)) >samples
[1] 1 2 3 4 5 6 7 8 9 10
Print out those sample numbers that are even using if else statement:
>for (thissample in samples) +{ + if (thissample %% 2 != 0) next + else print(thissample) +}
[1] 2 [1] 4 [1] 6 [1] 8 [1] 10
The
If we want all samples with number >6 be number 2, and those not be number 1, just:
>ret<-ifelse(samples>6,2,1) >ret
[1] 1 1 1 1 1 1 2 2 2 2