I have a data.frame called d. In this data.frame, some columns consist of constant numbers across the rows of the first column: study.name (see bel
d_list <- lapply(split(d,d$study.name),
#Find columns with similar values using sapply and length(unique(cols))
#then get the 1st row
function(x) x[1, sapply(x,function(y) length(unique(y))==1)])
do.call('rbind.data.frame',d_list)
study.name ESL prof ESL.1 prof.1
Bit.KnoA Bit.KnoA 1 3 1 3
Bit.KnoB Bit.KnoB 1 2 1 2
ChandlerA ChandlerA 1 2 1 2
Mubarak Mubarak 2 NA 2 NA
SheenA SheenA 1 2 1 2
Shin.Ellis Shin.Ellis 1 2 1 2
Sun Sun 2 2 2 2
Trus.Hsu Trus.Hsu 2 2 2 2