I have a dataset df and want to change table from 'narrow to fat'. Key made by compound variables (cert_id:obj_cd) and combine rows of month variable identified by key to one variable, say paid_months, with value 10,11,12 or whatever it was. How to do it? Thanks in advance!
df <- data.frame(
stringsAsFactors = FALSE,
cert_id = c(48L,48L,48L,48L,48L,48L,
48L,48L,48L,48L,48L,48L,48L,48L,48L,48L,48L,48L,
48L,48L),
sch_id = c("10001","10001","10001",
"10001","10001","10001","10001","10001","10001","10001",
"10001","10001","10005","10005","10005","10005",
"10005","10005","10005","10005"),
obj_id = c("40610","40610","40610",
"40612","40612","40612","40613","40613","40613","40614",
"40614","40614","3","3","4","4","40610","40610",
"40610","40612"),
obj_cd = c("S-OP-1b","S-OP-1b","S-OP-1b",
"S-OP-1d","S-OP-1d","S-OP-1d","S-OP-1e","S-OP-1e",
"S-OP-1e","S-OP-1f","S-OP-1f","S-OP-1f","S-3","S-3",
"S-4","S-4","S-OP-1b","S-OP-1b","S-OP-1b","S-OP-1d"),
month = c(10,11,12,10,11,12,10,11,
12,10,11,12,10,11,11,12,10,11,12,10)
)