[R] Select part of character row name in a data frame

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Thu Oct 19 18:01:08 CEST 2017

(Re-)read the discussion of indexing (both `[` and `[[`) and be sure to get clear on the difference between matrices and data frames in the Introduction to R document that comes with R. There are many ways to create numeric vectors, character vectors, and logical vectors that can then be used as indexes, including the straightforward way:

df[ c(
"Unique to strat          ",
"Unique to strat:crt.dummy                 ",
"Common to strat, and crt.dummy         ",
"Common to strat, and gender         ",
"Common to strat, and age                 ") ,]
Sent from my phone. Please excuse my brevity.

On October 19, 2017 3:14:53 AM PDT, Francesca PANCOTTO <f.pancotto at unimore.it> wrote:
>Thanks a lot, so simple so efficient!
>I will study more the grep command I did not know.
>Francesca Pancotto
>> Il giorno 19 ott 2017, alle ore 12:12, Enrico Schumann
><es at enricoschumann.net> ha scritto:
>>  df[grep("strat", row.names(df)), ]
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list