If ID are the same, I want to enter the calculated value with Locate column in the new row. If ID are not same, I want to represent it as 0.
I tried with for statement, however i had a hard in work.
help me!! please. thank you
this is my data and what I want to do.
>ID Locate
>10 2333
>10 5555
>10 2330
>10 1355
>12 1332
>12 1233
>12 1112
>13 3213
>14 3222
>14 5123
>14 6321
what i want to is
>ID Locate diff
>10 2333 0
>10 5555 3222
>10 2330 -3225
>10 1355 -975
>12 1332 0
>12 1233 -99
>12 1112 -121
>13 3213 0
>14 3222 0
>14 5123 1901
>14 6321 1198
this is my code....
rm <- c()
for ( i in 1:ncol(test))
{for ( j in 1:nrow(test))
{if(test[i,1]==test[i,2])
{c(test[i,j]-test[i,j+1])}
else
0
rm <- c(rm,i)}}