[R] Cutting vectors

Laurent Gautier Laurent.Gautier at lionbioscience.com
Mon Apr 3 12:31:46 CEST 2000


Does this helps ?


f _ function (var,fact,nlev) {
    c _ c()
    for (i in 1:length(nlev)) {
        c _ c(c,var[nlev[i] == fact])
    }
    return(c)
}



f(var,fact,nlev)






Laurent



You'll figure out easily how to get the levels....



Patrik Waldmann wrote:

> What I would like to do is as follows:
> I have a factor ex. fact 1 1 1 1 1 2 2 2 3 3 3 3 4 4 4 4, Levels:  1 2 3 4
> and a variable ex. var 11 12 13 14 15 21 22 23 31 32 33 34 41 42 43 44
> I take a bootstrap sample from the levels ex. nlev 1 1 4 3
> and would like to construct a new vector (variable) ex nvar that corresponds to the levels in nlev, nvar should then look like 11 12 13 14 15 11 12 13 14 15 41 42 43 44 31 32 33 34
> the next step would be to construct a new factor that corresponds to the size of the groups of nvar ex. nfact 1 1 1 1 1 2 2 2 2 2 3 3 3 3 4 4 4 4
>
> Patrik
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._





>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list