Dear RGroup
I have a requirement for which I am seeking help.
I am looking at automating the last column calculation through R when 
having the data of the other columns as a dataframe, In excel I can do 
using the formula function as given below, however, hereagain for the 
number of observations that come under control, I need to write the 
formula seperately for each cell and then I can block copy and paste to 
the rest of the data cells, however this can get tedious if there is too 
many observations.


Treatment
Candidate
Rep
L
a
b
Delta EcalculatedovercorrespondingcandidateandreplicateofControl
Control
1
1
23
3
2
=SQRT((D2-$D$2)*(D2-$D$2)+(E2-$E$2)*(E2-$E$2)+(F2-$F$2)*(F2-$F$2))
Control
1
2
25
2
1
=SQRT((D3-$D$3)*(D3-$D$3)+(E3-$E$3)*(E3-$E$3)+(F3-$F$3)*(F3-$F$3))
Control
2
1
27
1
3
=SQRT((D4-$D$4)*(D4-$D$4)+(E4-$E$4)*(E4-$E$4)+(F4-$F$4)*(F4-$F$4))
Control
2
2
29
3
1
=SQRT((D5-$D$5)*(D5-$D$5)+(E5-$E$5)*(E5-$E$5)+(F5-$F$5)*(F5-$F$5))
Treatment
1
1
25
2
2
=SQRT((D6-$D$2)*(D6-$D$2)+(E6-$E$2)*(E6-$E$2)+(F6-$F$2)*(F6-$F$2))
Treatment
1
2
27
3
5
=SQRT((D7-$D$3)*(D7-$D$3)+(E7-$E$3)*(E7-$E$3)+(F7-$F$3)*(F7-$F$3))
Treatment
2
1
29
2
2
=SQRT((D8-$D$4)*(D8-$D$4)+(E8-$E$4)*(E8-$E$4)+(F8-$F$4)*(F8-$F$4))
Treatment
2
2
30
3
2
=SQRT((D9-$D$5)*(D9-$D$5)+(E9-$E$5)*(E9-$E$5)+(F9-$F$5)*(F9-$F$5))
Treatment2
1
1
32
2
3
=SQRT((D10-$D$2)*(D10-$D$2)+(E10-$E$2)*(E10-$E$2)+(F10-$F$2)*(F10-$F$2))
Treatment2
1
2
35
1
3
=SQRT((D11-$D$3)*(D11-$D$3)+(E11-$E$3)*(E11-$E$3)+(F11-$F$3)*(F11-$F$3))
Treatment2
2
1
34
2
3
=SQRT((D12-$D$4)*(D12-$D$4)+(E12-$E$4)*(E12-$E$4)+(F12-$F$4)*(F12-$F$4))
Treatment2
2
2
28
2
1
=SQRT((D13-$D$5)*(D13-$D$5)+(E13-$E$5)*(E13-$E$5)+(F13-$F$5)*(F13-$F$5))


The result of the above formula call will give results in excel as below:


Treatment
Candidate
Rep
L
a
b
Delta EcalculatedovercorrespondingcandidateandreplicateofControl
Control
1
1
23
3
2
0
Control
1
2
25
2
1
0
Control
2
1
27
1
3
0
Control
2
2
29
3
1
0
Treatment
1
1
25
2
2
2.236067977
Treatment
1
2
27
3
5
4.582575695
Treatment
2
1
29
2
2
2.449489743
Treatment
2
2
30
3
2
1.414213562
Treatment2
1
1
32
2
3
9.110433579
Treatment2
1
2
35
1
3
10.24695077
Treatment2
2
1
34
2
3
7.071067812
Treatment2
2
2
28
2
1
1.414213562


Can someone help me figure out a way of acheiving this in R using a 
function call for the last column?
 Hope this example helps.


Regards
Vijayan Padmanabhan

Please visit us at www.itcportal.com
******************************************************************************
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. If you are the addressee, the contents of this email are intended 
for your use only and it shall not be forwarded to any third party, without 
first obtaining written authorisation from the originator or ITC Ltd./its 
Subsidiaries/its Group Companies. It may contain information which is 
confidential and legally privileged and the same shall not be used or dealt 
with by any third party in any manner whatsoever without the specific consent 
of ITC Ltd./its Subsidiaries/its Group Companies.
        [[alternative HTML version deleted]]

______________________________________________
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