#' A data transformation Function
#'
#' This function allows you to do data transformation.
#' @keywords transformation
#' @examples
#' data_transformation()
data_transformation <- function(D,variants){
# Assertion: stop if D is not a matrix
stopifnot(is.matrix(D))
# Store number of columns, number of rows
NC = dim(D)[2];NR = dim(D)[1];NRC = NC*NR
GM = mean(D)
AR = rowMeans(D);AC = colMeans(D)
SDR = apply(D,1,sd);SDC = apply(D,2,sd)
C = D
if(variants == 1){C = D-GM}
if(variants == 2){C = t(t(D)-AC)}
if(variants == 3){C = D-AR}
if(variants == 4){C = t(t(D)-AC)-AR+GM}
if(variants == 5){C = t(t(t(t(D)-AC))/SDC)}
if(variants == 6){C = (D-AR)/SDR}
if(variants == 7){C = D}
# ANOVA
# Compute sum of squares for rows and columns
DSSR = NC*sum((AR - GM)^2);DSSC = NR*sum((AC - GM)^2);DSST = sum((D-GM)^2)
## Sum of squares for RxC interactions
DSSRXC = DSST-DSSC-DSSR
## Degrees of freedom
DDFT = NRC - 1;DDFR = NR - 1;DDFC = NC - 1;DDFRXC = (NR-1)*(NC-1)
return(list(C = C,DSST=DSST,DSSR=DSSR,DSSC=DSSC,DDFT=DDFT,DDFR=DDFR,DDFC=DDFC,
DSSRXC=DSSRXC,DDFRXC=DDFRXC))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.