0
1

|
  • 22

2

0

|
  • 1
  • 1
1

fun <- function(dat) {
  L <- lapply(seq_along(dat), function(x, ...) {
    if (length(dat[x, dat[x, ] == 2, ]) >= 2) {
      range(names(dat[x, dat[x, ] == 2]))
    } else if (length(dat[x, dat[x, ] == 2, ]) == 1) {
      c(names(dat)[which(dat[x, ] == 2)], NA)
    }})
  setNames(data.frame(do.call(rbind, L)), c("t0", "t1"))
}

|
  • 1