0

I have three samples (1,2,3) and I measured three parameters (F,Fm and Fo) on days 5 and 10. I need to create a column “Sample” and gather the F, Fm and Fo columns. This is what I have:

Day  PAR  F1     F2     F3     Fm1   Fm2    Fm3   Fo1   Fo2   Fo3
5     0   0.10   0.20   0.30   0.50  0.60   0.70  0.90  1.00  1.10
10   20   0.11   0.21   0.31   0.51  0.61   0.71  0.91  1.01  1.11

This is how I need it

Sample  Day PAR      F    Fm     Fo
1       5    0     0.10  0.50   0.90
2       5    0     0.20  0.60   1.00
3       5    0     0.30  0.70   1.10
1       10   20    0.11  0.51   0.91
2       10   20    0.21  0.61   1.01
3       10   20    0.31  0.71   1.11

I would appreciate if someone could show me how to gather all three parameters in three different columns.

Cheers

Carlos
  • 47
  • 6
  • you may need `melt` `library(data.table);melt(setDT(df2), measure = patterns("^F\\d+$", "^Fm\\d+$", "^Fo\\d+$"), value.name = c("F", "Fm", "Fo"))` – akrun Oct 30 '17 at 10:39
  • thank you akrun for the link (https://stackoverflow.com/questions/12466493/reshaping-multiple-sets-of-measurement-columns-wide-format-into-single-columns). that's exactly what i needed and works – Carlos Nov 12 '17 at 04:10

0 Answers0