Sverre,

Try this:

my.list <- split(names(my.vector), my.vector)
my.list$base
my.list$recommended

Jean


`·.,,  ><(((º>   `·.,,  ><(((º>   `·.,,  ><(((º>

Jean V. Adams
Statistician
U.S. Geological Survey
Great Lakes Science Center
223 East Steinfest Road
Antigo, WI 54409  USA



From:
Sverre Stausland <john...@fas.harvard.edu>
To:
r-help@r-project.org
Date:
08/02/2011 01:24 PM
Subject:
[R] Extract names from vector according to their values
Sent by:
r-help-boun...@r-project.org



Dear helpers,

I can create a vector with the priority of the packages that came with
R, like this:

> installed.packages()[,"Priority"]->my.vector
> my.vector
         base          boot         class       cluster     codetools
       "base" "recommended" "recommended" "recommended" "recommended"
     compiler      datasets       foreign      graphics     grDevices
       "base"        "base" "recommended"        "base"        "base"
         grid    KernSmooth       lattice          MASS        Matrix
       "base" "recommended" "recommended" "recommended" "recommended"
      methods          mgcv          nlme          nnet         rpart
       "base" "recommended" "recommended" "recommended" "recommended"
      spatial       splines         stats        stats4      survival
"recommended"        "base"        "base"        "base" "recommended"
        tcltk         tools         utils
       "base"        "base"        "base"

How can I extract the names from this vector according to their
priority? I.e. I want to create a vector from this with the names of
the "base" packages, and another vector with the names of the
"recommended" packages.

Thank you
Sverre

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to