Hi. I have a data frame (data1) with student classroom observation. So there are six students and there are three parameters (reading, demo and reprimand). Reading1 corresponds to student1, reading2 corresponds to student2 and so on.
I want to transpose this data and make it appear as in data2. How can I do this?
data1<-tibble::tribble(
~student1, ~student2, ~student3, ~student4, ~student5, ~student6, ~reading1, ~demo1, ~reprimand1, ~reading2, ~demo2, ~reprimand2, ~reading3, ~demo3, ~reprimand3, ~reading4, ~demo4, ~reprimand4, ~reading5, ~demo5, ~reprimand5, ~reading6, ~demo6, ~reprimand6,
"abc", "pqr", "xyz", "rst", "def", "ghi", 0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L
)
data2<-tibble::tribble(
~student, ~reading, ~demo, ~reprimand,
"abc", 0L, 1L, 0L,
"pqr", 1L, 0L, 1L,
"xyz", 1L, 1L, 0L,
"rst", 1L, 0L, 0L,
"def", 0L, 1L, 0L,
"ghi", 1L, 0L, 1L
)
Created on 2022-06-11 by the reprex package (v2.0.1)