I have 2 data frames.
Df1:
Treatment Time Species Base mn h
<fct> <fct> <fct> <fct> <dbl> <dbl>
1 TR T1 A C 0.340 0.00435
2 TR T2 A C 0.329 0.00679
3 TR T1 B C 0.336 0.00429
4 TR T2 B C 0.328 0.00701
5 UTC T0 UTC C 0.312 0.00542
6 TR T1 A H 0.350 0.00256
7 TR T2 A H 0.315 0.00525
8 TR T1 B H 0.346 0.00181
9 TR T2 B H 0.317 0.00400
10 UTC T0 UTC H 0.344 0.00384
11 TR T1 A L 0.18 0.00382
12 TR T2 A L 0.219 0.00617
13 TR T1 B L 0.198 0.00570
14 TR T2 B L 0.223 0.00567
15 UTC T0 UTC L 0.191 0.00601
16 TR T1 A S 0.131 0.00117
17 TR T2 A S 0.137 0.00530
18 TR T1 B S 0.120 0.00406
19 TR T2 B S 0.133 0.00310
20 UTC T0 UTC S 0.153 0.00176
and Df2:
Species Variety Time Value Residual_p
<fct> <fct> <fct> <dbl> <dbl>
1 UTC Blue T0 0.00000000 1.0000000
2 A Blue T1 0.03136850 0.9686315
3 A Blue T2 0.17359611 0.8264039
4 B Blue T1 0.03734234 0.9626577
5 B Blue T2 0.10303113 0.8969689
6 UTC Green T0 0.00000000 1.0000000
7 A Green T1 0.04072433 0.9592757
8 A Green T2 0.09362780 0.9063722
9 B Green T1 0.03092473 0.9690753
10 B Green T2 0.07051702 0.9294830
I create a third data frame where 1:4 columns are the same of Df1 by taping
Df_Blue<-Df1[,1:4]
Then I have to create the column 5 in Df_Blue where rows are the product of multiplying Df1$mn by Df2$Residual_p but factors Species and Time must match and only rows of Df2$Variety == "Blue" should be considered.
Hope it's clear.
Thank you!