Francesca PANCOTTO
2017-Oct-19 10:14 UTC
[R] Select part of character row name in a data frame
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]]
Jeff Newmiller
2017-Oct-19 16:01 UTC
[R] Select part of character row name in a data frame
(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.
Francesca PANCOTTO
2017-Oct-20 08:17 UTC
[R] Select part of character row name in a data frame
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.