Re: [R] determining the column index and grabbing only variables with a certain string in them

From: Xiaohui <chenxh007_at_gmail.com>
Date: Tue, 26 Jun 2007 12:40:05 -0700

  1. which("Exat Name" == names(Data) ## Assuming Data is your data.frame
  2. grep("Variable", names(Data))

Xiaohui

Dimitri Liakhovitski wrote:
> Hello!
>
> I have a data set with almost 2,000 variables (called 'Data').
> I want to select only a set of variables that have a certain string in
> them (e.g., "Variable") - 'Variable.1', 'Variable.2', etc. until
> 'Variable.20'.
>
> 2 questions:
>
> 1. How can I determine the exact column index of a variable in the
> data frame if I know its exact name? (I am asking because names(Data)
> allows me to see only the last 1,348 variables)
> 2. How can I grab only variables that have a string "Variable" in
> their name using grep?
>
> Thank you!
> Dimitri
>
> ______________________________________________
> 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.
>
>



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. Received on Tue 26 Jun 2007 - 20:07:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Jun 2007 - 20:34:02 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.