mtb954 at gmail.com
2007-Mar-26 19:06 UTC
[R] How to drop variables using a wildcard and logic...
Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter "t" I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]]
Benilton Carvalho
2007-Mar-26 19:19 UTC
[R] How to drop variables using a wildcard and logic...
if 'test' is your data frame...
test[, grep("[tT]$", names(test))]
b
On Mar 26, 2007, at 3:06 PM, mtb954 at gmail.com wrote:
> Dear R users
>
> I would like to make a new dataframe from an existing dataframe,
> retaining
> ONLY those variables that end in the letter "t"
>
> I have searched the help archives and consulted several reference
> books but
> cannot seem to find an example.
>
> Any ideas...? Thanks!
>
> Mark
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
mtb954 at gmail.com
2007-Mar-26 19:42 UTC
[R] How to drop variables using a wildcard and logic...
Thanks Phil and Benilton! Mark On 3/26/07, mtb954@gmail.com <mtb954@gmail.com> wrote:> > Dear R users > > I would like to make a new dataframe from an existing dataframe, > retaining ONLY those variables that end in the letter "t" > > I have searched the help archives and consulted several reference books > but cannot seem to find an example. > > Any ideas...? Thanks! > > Mark >[[alternative HTML version deleted]]