search for: mylevel

Displaying 4 results from an estimated 4 matches for "mylevel".

Did you mean: mylevels
2003 Oct 02
3
indexing a vector
Dear All: I'd like to know how to sort and then index a vector of floats by several levels in R. For example >x<-rnorm(100) > MyLevels<-quantile(x,probs=c(0,.5,1)) > MyLevels 0% 50% 100% -2.11978442 -0.03770613 2.00186397 next i want to replace each x[i] in x by 1,2,3 or 4 depending on which quantile that x[i] falls. How do I do that in a "vector" fashion? I tried something like >f...
2009 May 06
4
tapply changing order of factor levels?
Hi, Does tapply change the order when applied on a factor? Below is the code I tried. > mylevels<-c("IN0020020155","IN0019800021","IN0020020064") > mydata<-c("IN0020020155","IN0019800021","IN0020020064","IN0020020155","IN0019800021","IN0019800021","IN0020020064","IN0020020064&quot...
2007 Jun 08
1
How to make a table of a desired dimension
Hi ComRades, I want to make a matrix of frequencies from vectors of a continuous variable spanning different values. For example this code x<-c(runif(100,10,40),runif(100,43,55)) y<-c(runif(100,7,35),runif(100,37,50)) z<-c(runif(100,10,42),runif(100,45,52)) a<-table(ceiling(x)) b<-table(ceiling(y)) c<-table(ceiling(z)) a b c will give me three tables that start and end at
2011 Nov 04
2
Efficiency of factor objects
....time(replicate(1e4,{q1<-f1[100:200];1})) user system elapsed 0.67 0.00 0.68 Putting the levels vector in an environment speeds up subsetting: myfactor <- function(...) { f <- factor(...) g <- unclass(f) class(g) <- "myfactor" attr(g,"mylevels") <- as.environment(list(levels=attr(f,"mylevels"))) g } `[.myfactor` <- function (x, ...) { y <- NextMethod("[") attributes(y) <- attributes(x) y } > m1 <- myfactor(f1) > system.time(replicate(1e4,{q1<-m1[100:200];1})) user sy...