Perhaps this is a bit redundant but still, it bothers me a bit. Why do I need to turn a vector into an integer class
to get the element-wise comparison correct?
# Finding a linear combination of v, in terms of u1,u2,u3
v=c(3,7,-4)
u1=c(1,2,3)
u2=c(2,3,7)
u3=c(3,5,6)
# L. System AX=B
A <- cbind(u1,u2,u3)
B <- v
k <- solve(A,B)
k
## Therefore
u <- k[1]*u1+k[2]*u2+k[3]*u3
# First elemement FALSE?
v==u
identical(v,u)
all(v==u)
v %in% u
#Both numeric
is.numeric(v)==is.numeric(u)
u <- as.integer(u)
# The elemnt-wise comparison is now correct, identical FALSE, because they are a different class.
v==u
identical(v,u)
all(v==u)
v %in% u