正在加载图片...
1p1ots.tex,b2648c8on2011/04/01 manipulating biplots(Gower and Hand,1996),in 2D or 3D.For those who are seeking a more direct application of the commands discussed here,you can try to adapt the sphpca function in the psy package(Falissard,1996). 4 Back to the basics So far,we only talked about dedictaed environments for interactive visualization.However, the base R functionalities might still prove to be useful in some cases.In fact,the tcltk package offers a simple way to attach interactive buttons to the current device. Let's say we want to intercatively display the most extremes individuals on a given matrix of scores.'Extreme'could mean many things,but for now assume this is a percentile-based measure,for example the 5e and 95e percentile are used to flag individuals having extreme low or high scores. filter.perc <function(x,cutoff=c(.05,.95),id=NULL,collate=FALSE){ lh <quantile(x,cutoff,na.rm=TRUE) out <-list(x.low=which(x Ih[1]),x.high=which(x 1h[2])) if (!is.null(id)){ out [["x.low"]]<-id[out [["x.low"]]] out [["x.high"]]<-id[out [["x.high"]]] if (collate) out <unique(c(out [["x.low"]],out [["x.high"]])) return(out) n<-500 scores <-replicate(5,rnorm(n,mean=sample(20:40,1))) idx <-apply(scores,2,filter.perc,id=NULL,collate=TRUE) my.col <-as.numeric(1:n %in%unique(unlist(idx)))+1 splom(-scores,pch=19,col=my.col,alpha=.5,cex=.6) A simple display for the distribution of these five series of scores is shown below,with individuals in red corresponding to those being in the lowest or highest fifth percentile.(Also,keep in mind that is done in a purely univariate manner.) Now,what about varying the thresholds for highlighting individuals?Instead of repeating the same steps,we could simply add a dynamic selector to this display. Using aplpack:slider.this can be implemented as follows: do.it <-function() require(aplpack) update.display <function(...){ value <-slider(no=1) idx <-apply(scores,2,filter.perc,cutoff=c(value,1-value), id=NULL,collate=TRUE) slens!A d ●●●●●●●●R Visuals iplots.tex, b2648c8 on 2011/04/01 manipulating biplots (Gower and Hand, 1996), in 2D or 3D. For those who are seeking a more direct application of the commands discussed here, you can try to adapt the sphpca function in the psy package (Falissard, 1996). 4 Back to the basics So far, we only talked about dedictaed environments for interactive visualization. However, the base R functionalities might still prove to be useful in some cases. In fact, the tcltk package offers a simple way to attach interactive buttons to the current device. Let’s say we want to intercatively display the most extremes individuals on a given matrix of scores. ‘Extreme’ could mean many things, but for now assume this is a percentile-based measure, for example the 5e and 95e percentile are used to flag individuals having extreme low or high scores. filter.perc <- function(x, cutoff=c(.05, .95), id=NULL, collate=FALSE) { lh <- quantile(x, cutoff, na.rm=TRUE) out <- list(x.low=which(x < lh[1]), x.high=which(x > lh[2])) if (!is.null(id)) { out[["x.low"]] <- id[out[["x.low"]]] out[["x.high"]] <- id[out[["x.high"]]] } if (collate) out <- unique(c(out[["x.low"]], out[["x.high"]])) return(out) } n <- 500 scores <- replicate(5, rnorm(n, mean=sample(20:40, 1))) idx <- apply(scores, 2, filter.perc, id=NULL, collate=TRUE) my.col <- as.numeric(1:n %in% unique(unlist(idx))) + 1 splom(~ scores, pch=19, col=my.col, alpha=.5, cex=.6) A simple display for the distribution of these five series of scores is shown below, with individuals in red corresponding to those being in the lowest or highest fifth percentile. (Also, keep in mind that is done in a purely univariate manner.) Now, what about varying the thresholds for highlighting individuals? Instead of repeating the same steps, we could simply add a dynamic selector to this display. Using aplpack::slider, this can be implemented as follows: do.it <- function() { require(aplpack) update.display <- function(...) { value <- slider(no=1) idx <- apply(scores, 2, filter.perc, cutoff=c(value, 1-value), id=NULL, collate=TRUE)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有