[R] rows extraction

David L Carlson dcarlson at tamu.edu
Wed Sep 26 17:28:42 CEST 2012


> subtest <- subset(test, Name. %in% c("PKB123", "PKB22", "PKB23", "PKB32",
           "CTV19", "CTV20", "PKB11", "PKB11"))
> subtest
    Name. Score performance Environment.
10  CTV19     2  0.52740797   0.53639048
11  CTV20     3  0.05298615   0.04856818
12  PKB11     4  0.90037809   0.79427806
13  PKB11     5  0.41806588   0.40839968
14 PKB123     5  0.16914593   0.17565094
15  PKB22     4  0.13450181   0.14681555
16  PKB23     3  0.05703352   0.04438428
17  PKB32     2  0.07606024   0.07606045

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352



> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Nico Met
> Sent: Wednesday, September 26, 2012 10:20 AM
> To: r-help
> Subject: [R] rows extraction
> 
> Dear all,
> 
> I want to extract rows from a data frame shown here as "test". For
> example:
> rows with with sorting
>  PKB123  PKB22  PKB23  PKB32  CTV19  CTV20  PKB11  PKB11
> 
> > dput(test)
> structure(list(Name. = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
> 8L, 9L, 10L, 11L, 12L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
> 19L), .Label = c("CTV10", "CTV11", "CTV12", "CTV13", "CTV14",
> "CTV15", "CTV16", "CTV17", "CTV18", "CTV19", "CTV20", "PKB11",
> "PKB123", "PKB22", "PKB23", "PKB32", "PKB54", "PKB55", "PKB65"
> ), class = "factor"), Score = c(1, 3, 4, 5, 2, 3, 4, 5, 6, 2,
> 3, 4, 5, 5, 4, 3, 2, 5, 6, 6, 2), performance = c(0.1885092462,
> 0.0794777814, 0.2503300253, 0.0378809048, 0.7203585833, 0.0517920055,
> 0.2064060066, 0.5514853303, 0.2605452552, 0.5274079653, 0.0529861537,
> 0.9003780927, 0.4180658816, 0.1691459321, 0.1345018054, 0.0570335197,
> 0.0760602378, 0.2203198271, 0.2233031679, 0.0355550859, 0.6791582042
> ), Environment. = c(0.1936732121, 0.1073581974, 0.2399158958,
> 0.0370952629, 0.6749189555, 0.0545192018, 0.2067554284, 0.4832804062,
> 0.2784950304, 0.5363904829, 0.0485681822, 0.7942780565, 0.4083996821,
> 0.175650937, 0.1468155515, 0.0443842831, 0.0760604527, 0.2029511384,
> 0.2486623715, 0.0362999435, 0.6409256796)), .Names = c("Name.",
> "Score", "performance", "Environment."), class = "data.frame",
> row.names =
> c(NA,
> 21L))
> 
> 
> regards
> 
> Nico
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list