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

Francesca PANCOTTO 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.

f.

----------------------------------
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.
>> 
>> Thanks!
>> 
>> 
>> 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
>> 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