Hi
I have a dataframe as below:
x1 y1 x2 y2 x3 y3 output
2 100 190 99 1430 79 89
2 100 192 63 1431 75 69
2 100 192 63 1444 51 57
3 0 195 99 1499 50 74.5
3 0 198 98 1500 80 89
30 0 198 100 1451 97 65.66666667
32 100 868 100 1451 97 99
33 82 870 100 1490 97 93
33 0 871 82 1494 85 55.66666667
In reality the dataframe has pairs of columns x & y up to a large number.
As you can see from the column labelled output in the dataframe; I want to
calculate the mean of each row of the yn columns, but only to include each
yn value in the calculation of the mean if the corresponding xn column
value is greater than 10.
So for row 1; you will see that only y2 & y3 are included in calculating
the output column, but for row 6 y1-y3 are all included.
Because the number of paired x & y columns is large I am not sure the best
way to achieve this.
Thanks in advance
Tom
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.