I want to calculate the distance between multiple rows in a series using R. There are 967 X 35 data table. The table array is as below.
1. 6.23 3.3 4.36 3.9 ---- 4.50 1.50 3.35 (35 column)
2. 5.00 2.3 3.36 4.39 ---- 2.52 3.40 2.37 (35 column)
3. 5.23 2.6 5.64 4.23 ---- 3.50 4.55 3.48 (35 column)
What if I want to calculate the distance between each cells of each rows? For example, let's say I want to calculate the distance between row 1 and row2 / between row 2 and row 3 and so on.
Then the math formula for calculating the distance will be...
Square root of {(6.23-5)^2 +(3.3-2.3)^2+(4.36-3.36)^2+(3.9-4.39)^2+------- + (4.5-2.52)^2+(1.5-3.4)^2+(3.35-2.37)^2}
and will do the same calculation to every other two rows (1-2row, 2-3row, 3-4row, ….., 967-1 row (967 times))
But I don't know how to code this methodology in R.
I uploaded the data table. (Called "R_skills")
Then using R, I coded as below.
- 'Read.xlsx(R_skills)'
2.
sample.matrix<-matrix(c(1:33635,ncol=35)
paralleldist(x=sample.mtarix,method="dtw")
Error: unexpected symbol in: "sample.matrix<-matrix(c(1:33635,ncol=35) paralleldist"