Dear useRs,
i have the following data arranged in three columns

structure(c(0.492096635764151, 0.433332688044914, 0.521585941816778, 
1.66472272302545, 2.61878329527404, 2.19154489521664, 0.493876245329722, 
0.4915787202584, 0.889477365620806, 0.609135860199222, 0.739201878930367, 
0.854663750519518, 2.06195904001605, 1.41493262330451, 1.35748791897328, 
1.19490680241894, 0.702488756183322, 0.338258418490199, 0.123398398622741, 
0.138548982660226, 0.16170889185798, 0.414543218677095, 1.84629295875002, 
2.24547399004563), .Dim = c(12L, 2L))

The distance is to be calculated by subtracting each value of each column from 
the corresponding column value in the following way
=>The column values are cyclic. For example, after row 12 there is once again 
row 1. So, in a way, row 3 is more closer to row 12 than to row 8. 
=> The peak value is the maximum value for any column. the values falling in 
the range of 80% of the maximum values can also be considered as maximum value 
provided they are not falling immediatly next to eachother. 
=> If we plot column 1 and column 2 the peak value of column 1 is at 5th grade 
of x-axis and for column 2 its in 12th. For column 2 at x=1 the value is very 
close to that of the value at x=12 (in 80% range of it), but still it can 
considered as peak value as it is immediatly falling next to the maximum value. 
Now The peaks are moved towards eachother in a shortest possible way unless 
maximum values are under eachother
more precisely,
column 1 
1 2 3 4 5(max) 6 7 8 9 10 11 12        column 2 
1 2 3 4 5 6 7 8 9 10 11 12(max)
Now distance is measured in the following way
column 1 
1 2 3 4 5(max) 6 7 8 9 10 11 12        column 2 
12(max) 1 2 3 4 5 6 7 8 9 10 11 
a>sum(abs(col1-col2))
==column 1 
1 2 3 4 5(max) 6 7 8 9 10 11 12        column 2 
11 12(max) 1 2 3 4 5 6 7 8 9 10  
b>sum(abs(col1-col2))==column 1 
1 2 3 4 5(max) 6 7 8 9 10 11 12        column 2 
10 11 12(max) 1 2 3 4 5 6 7 8 9 
c>sum(abs(col1-col2))==column 1 
1 2 3 4 5(max) 6 7 8 9 10 11 12        column 2 
9 10 11 12(max) 1 2 3 4 5 6 7 8 
d>sum(abs(col1-col2))==column 1 
1 2 3 4 5(max) 6 7 8 9 10 11 12        column 2 
8 9 10 11 12(max) 1 2 3 4 5 6 7 
e>sum(abs(col1-col2))

total distance= a+b+c+d+e
For the following two column it should work the following way

structure(c(0.948228727226247, 1.38569091844218, 0.910510759802679, 
1.25991218521949, 0.993123416952421, 0.553640392997634, 0.357487763503204, 
0.368328033777003, 0.344255688489322, 0.423679560916755, 1.32093576037521, 
3.13420679229785, 0.766278117577654, 0.751997501086888, 0.836280758630117, 
1.188156460303, 1.56771616670373, 1.15928168139479, 0.522523036011874, 
0.561678840701488, 1.11155735914479, 1.26467106348848, 1.09378883406298, 
1.17607018089421), .Dim = c(12L, 2L))
column 1 
1 2 3 4 5 6 7 8 9 10 11 12(max)        column 2 
1 2 3 4 5(max) 6 7 8 9 10(max) 11 12
Now as for column 2, 10th value is closer to col1 maximum value, therefore 
distance is measured in the following way
column 1 
1 2 3 4 5 6 7 8 9 10 11 12(max)        column 2 
12 1 2 3 4 5 6 7 8 9 10(max) 11
a>sum(abs(col1-col2))
---
column 1 
1 2 3 4 5 6 7 8 9 10 11 12(max)        column 2 
11 12 1 2 3 4 5 6 7 8 9 10(max) 
b>sum(abs(col1-col2))
total distance=a+b
How can i do it??
Thankyou very very much in advance
Elisa
                                          
i have the following data arranged in three columns


structure(c(0.492096635764151, 0.433332688044914, 0.521585941816778, 
1.66472272302545, 2.61878329527404, 2.19154489521664, 0.493876245329722, 
0.4915787202584, 0.889477365620806, 0.609135860199222, 0.739201878930367, 
0.854663750519518, 2.06195904001605, 1.41493262330451, 1.35748791897328, 
1.19490680241894, 0.702488756183322, 0.338258418490199, 0.123398398622741, 
0.138548982660226, 0.16170889185798, 0.414543218677095, 1.84629295875002, 
2.24547399004563), .Dim = c(12L, 2L))


The distance is to be calculated by subtracting each value of each column from 
the corresponding column value in the following way

=>The column values are cyclic. For example, after row 12 there is once again 
row 1. So, in a way, row 3 is more closer to row 12 than to row 8. 

=> The peak value is the maximum value for any column. the values falling in 
the range of 80% of the maximum values can also be considered as maximum value 
provided they are not falling immediatly next to eachother. 

=> If we plot column 1 and column 2 the peak value of column 1 is at 5th grade 
of x-axis and for column 2 its in 12th. 
For column 2 at x=1 the value is very close to that of the value at x=12 (in 
80% range of it), but still it can considered as peak value as it is immediatly 
falling next to the maximum value. 
Now The peaks are moved towards eachother in a shortest possible way unless 
maximum values are under eachother
more precisely,

column 1 

1 2 3 4 5(max) 6 7 8 9 10 11 12
        
column 2 

1 2 3 4 5 6 7 8 9 10 11 12(max)

Now distance is measured in the following way

column 1 

1 2 3 4 5(max) 6 7 8 9 10 11 12
        
column 2 

12(max) 1 2 3 4 5 6 7 8 9 10 11 

a>sum(abs(col1-col2))

==
column 1 

1 2 3 4 5(max) 6 7 8 9 10 11 12
        
column 2 

11 12(max) 1 2 3 4 5 6 7 8 9 10  

b>sum(abs(col1-col2))
==
column 1 

1 2 3 4 5(max) 6 7 8 9 10 11 12
        
column 2 

10 11 12(max) 1 2 3 4 5 6 7 8 9 

c>sum(abs(col1-col2))
==
column 1 

1 2 3 4 5(max) 6 7 8 9 10 11 12
        
column 2 

9 10 11 12(max) 1 2 3 4 5 6 7 8 

d>sum(abs(col1-col2))
==
column 1 

1 2 3 4 5(max) 6 7 8 9 10 11 12
        
column 2 

8 9 10 11 12(max) 1 2 3 4 5 6 7 

e>sum(abs(col1-col2))


total distance= a+b+c+d+e

For the following two column it should work the following way


structure(c(0.948228727226247, 1.38569091844218, 0.910510759802679, 
1.25991218521949, 0.993123416952421, 0.553640392997634, 0.357487763503204, 
0.368328033777003, 0.344255688489322, 0.423679560916755, 1.32093576037521, 
3.13420679229785, 0.766278117577654, 0.751997501086888, 0.836280758630117, 
1.188156460303, 1.56771616670373, 1.15928168139479, 0.522523036011874, 
0.561678840701488, 1.11155735914479, 1.26467106348848, 1.09378883406298, 
1.17607018089421), .Dim = c(12L, 2L))

column 1 

1 2 3 4 5 6 7 8 9 10 11 12(max)
        
column 2 

1 2 3 4 5(max) 6 7 8 9 10(max) 11 12

Now as for column 2, 10th value is closer to col1 maximum value, therefore 
distance is measured in the following way

column 1 

1 2 3 4 5 6 7 8 9 10 11 12(max)
        
column 2 

12 1 2 3 4 5 6 7 8 9 10(max) 11

a>sum(abs(col1-col2))

---

column 1 

1 2 3 4 5 6 7 8 9 10 11 12(max)
        
column 2 

11 12 1 2 3 4 5 6 7 8 9 10(max) 

b>sum(abs(col1-col2))

total distance=a+b

How can i do it..

Thankyou very very much in advance

Elisa
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to