[R] Select part of character row name in a data frame
f.pancotto at unimore.it
Fri Oct 20 10:17:03 CEST 2017
I did not need to select the whole character sentence, otherwise I would know how to do it.. from basic introduction to R as you suggest.
Grep works perfectly.
Francesca Pancotto, PhD
> Il giorno 19 ott 2017, alle ore 18:01, Jeff Newmiller <jdnewmil at dcn.davis.CA.us> ha scritto:
> (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