2012年3月13日星期二

transform count-data into binary coded data


1
2
3
4
5
6
7
8
count1 <- count2 <- count3 <- count4 <- sample(c(rep(0, 10), 1:10))
some <- LETTERS[1:20] 
thing <- letters[1:20] 
mydf <- data.frame(count1, count2, count3, count4, some, thing)
ids <- grep("count", names(mydf))
myfun <- function(x) {ifelse(x > 0, 1, 0)}
mydf[, ids] <- lapply(mydf[, ids], myfun)


没有评论:

发表评论