0

This may be a very daft question but I have been trying to achieve it and have not yet succeeded. I have a dataframe that looks like this:

df <- data.frame(Participant = c("PAH12", "COKJA","PAH12", "COKJA","PAH12", "COKJA" ), Measure = c("A", "A", "B", "B", "C", "C"), Group = c("1", "2", "1", "2", "1", "2"), Value = c(11, 15, 20, 17, 23, 7))

  Participant Measure Group Value
1       PAH12       A     1    11
2       COKJA       A     1    15
3       PAH12       B     1    20
4       COKJA       B     2    17
5       PAH12       C     2    23
6       COKJA       C     2     7

I want to break the column "measure" into separate ones with the corresponding values below as demonstrated in the reproducible code below:

df2 <- data.frame(Participant = c("PAH12", "COKJA"), A = c(11, 15), B = c(20,17), C = c(23,7), Group = c("1","2"))

  Participant  A  B  C Group
1       PAH12 11 20 23     1
2       COKJA 15 17  7     2

How can I achieve this?

CatM
  • 284
  • 2
  • 12

0 Answers0