I am trying to make a random sequence with sample
when condition is TRUE. But it gives a sigle element, instead of whole sequence.
A <- 2
B <- 3
Condition <- TRUE
# all 6 elements are printed randomly.
print(sample(A*B, A*B))
# all 6 elements are printed in order.
print(1:(A*B))
Q <- ifelse(TRUE, sample(A*B, A*B), 1:(A*B))
# only ONE element is printed.
print(Q)
interestingly the ifelse
gives the unexpected result (as attached) . Please advise.
I am with MRO 3.5.3 on ubuntu 1804