0

I have two data frames. DF1 contains all of the details associated with a treatment with a treatment number applied to each treatment e.g.

dput(DF1)
structure(list(Depth = c(150L, 150L, 300L, 300L, 150L, 150L, 
300L, 300L), TinePoint = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 
1L, 2L), .Label = c("Thin", "Wide"), class = "factor"), Config = structure(c(1L, 
1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("Module", "Tine"), class = "factor"), 
TreatmentNumber = 1:8), .Names = c("Depth", "TinePoint", 
"Config", "TreatmentNumber"), class = "data.frame", row.names = c(NA, 
-8L))

The other data frame (DF2) contains all of the details associated with each treatment as well as the observations but does not contain the treatment number.

dput(head(DF2))
structure(list(Depth = c(300L, 150L, 150L, 300L, 150L, 150L), 
TinePoint = structure(c(1L, 1L, 1L, 1L, 1L, 2L), .Label = c("Thin", 
"Wide"), class = "factor"), Config = structure(c(2L, 1L, 
2L, 1L, 2L, 2L), .Label = c("Module", "Tine"), class = "factor"), 
Value = c(54L, 49L, 40L, 33L, 58L, 11L)), .Names = c("Depth", 
"TinePoint", "Config", "Value"), row.names = c(NA, 6L), class = "data.frame")

How do I use DF1 to add a new column with the correct treatment number to DF2?

The data shown here is for example only, my actual data set is much larger. I have tried using an ifelse function but my actual data has 16 treatments so this becomes unwieldy very quickly.

0 Answers0