I am new user in R. How can I check which elements of the vector A is between the elements of vector B for example:
A = c(1.1,
You want some variant of findInterval
findInterval(A,B)
[1] 1 3 3 3 3 2
Value 1 indicates it is between 1 and 2 (the lowest and next lowest value in B) Value 2 indicates it is between 2 and 3
So to find which ones are between
which(findInterval(A,B) %in% seq_len(length(unique(B))-1))
# [1] 1 6
and to extract from A
A[findInterval(A,B) %in% seq_len(length(unique(B))-1)]
# [1] 1.1 2.2
You could also use cut, which will create a factor.
In conjunction with split this will give
split(A, cut(A,B),drop=FALSE)
$`(1,2]`
[1] 1.1
$`(2,3]`
[1] 2.2