a.str <- matrix(c(‘1′,’2′,’3′,’5′,NA,’6′)
+ ,c(2,3),dimnames = list(c(‘g1′,’g2′),c(‘t1′,’t2′,’t3′)))
a.str
# t1 t2 t3
# g1 “1” “3” NA
# g2 “2” “5” “6”
a.num <- apply(a.str, c(1,2), as.numeric)
a.num
# t1 t2 t3
# g1 1 3 NA
# g2 2 5 6
Note: 第一行,第一列位置要为空!!
Recent Comments