I have a matrix that holds location information by coordinates(e.g. (1,1)) of a 38*35 matrix.
##(1,1) (1,2) (1,3) (1,4) .... (1,38)
##(2,1) ....
##....
##(35,38)
I have created each point into a vector array, so that (1,1)=1, (1,2)=2, ... (2,1)=39, (2,2)=40, .... (35, 38)=1330 and so on.
#1
#2
#3
#4
#5
#6
#7
#8
...
#1330
The plan is to put in prediction data point P and find out the Euclydian distance between P and the actual data X. It is no problem until both points are on the same row (the distance would equal the subtraction of the two numbers), but if the two data I'm comparing fall on different rows, it becomes a problem.
For instance, " would actually mean (2,2) and I cannot subtract anymore.
I've been trying creating if
statements, but it seems to be getting complicated.
#original data: x, predicted data:p
if(p<39){
distance <- abs(p-x)
} else if(x<77){
distance <- (sqrt(1)^2+((p-38)^2)
}