## by row medianCenter <- function(y){ y <- apply(y, 1, function(x){x-median(x)}) scale(t(y), center=FALSE) } ## by col medianCenter <- function(y){ y <- apply(y, 2, function(x){x-median(x)}) scale(y, center=FALSE) }
欢迎来到糗糗的世界
## by row medianCenter <- function(y){ y <- apply(y, 1, function(x){x-median(x)}) scale(t(y), center=FALSE) } ## by col medianCenter <- function(y){ y <- apply(y, 2, function(x){x-median(x)}) scale(y, center=FALSE) }