#############################################################################
# EXAMPLE 1: z-standardization data.internet
#############################################################################
data(data.internet)
dat <- data.internet
# z-standardize all variables in this dataset
zdat <- ma.scale2( dat , missings=TRUE )
## Not run:
# #############################################################################
# # SIMULATED EXAMPLE 2: Speed comparison for many cases and many variables
# #############################################################################
#
# set.seed(9786)
# # 3000 cases, 200 variables
# N <- 3000
# p <- 200
# # simulate some data
# x <- matrix( stats::rnorm( N*p ) , N , p )
# x <- round( x , 2 )
#
# # compare computation times for 10 replications
# B <- 10
# s1 <- Sys.time() # scale in R
# for (bb in 1:B){
# res <- scale(x)
# } ; s2 <- Sys.time() ; d1 <- s2-s1
#
# s1 <- Sys.time() # scale in miceadds
# for (bb in 1:B){
# res1 <- ma.scale2(x)
# } ; s2 <- Sys.time() ; d2 <- s2-s1
#
# # scale in miceadds with missing handling
# s1 <- Sys.time()
# for (bb in 1:B){
# res1 <- ma.scale2(x,missings=TRUE)
# } ; s2 <- Sys.time() ; d3 <- s2-s1
# d1 # scale in R
# d2 # scale in miceadds (no missing handling)
# d3 # scale in miceadds (with missing handling)
# ## > d1 # scale in R
# ## Time difference of 1.622431 secs
# ## > d2 # scale in miceadds (no missing handling)
# ## Time difference of 0.156003 secs
# ## > d3 # scale in miceadds (with missing handling)
# ## Time difference of 0.2028039 secs
# ## End(Not run)
Run the code above in your browser using DataLab