Re: [R] Choosing columns by number

2015-08-25 Thread Thierry Onkelinx
Here are a few ideas. data.frame( seq_along(iris), colnames(iris) ) which(colnames(iris) %in% c(Sepal.Width, Petal.Width)) grep(\\.Width$, colnames(iris)) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg /

Re: [R] Choosing columns by number

2015-08-25 Thread David L Carlson
Subject: Re: [R] Choosing columns by number Thierry's answer of: data.frame( seq_along(iris), colnames(iris) ) is exactly what I was looking for. Apologies for vagueness and HTML. It was unintended. Sam On Tue, Aug 25, 2015 at 8:32 AM, stephen sefick ssef...@gmail.com wrote: ?grep I think

Re: [R] Choosing columns by number

2015-08-25 Thread David Winsemius
-project.org Subject: Re: [R] Choosing columns by number Thierry's answer of: data.frame( seq_along(iris), colnames(iris) ) is exactly what I was looking for. Apologies for vagueness and HTML. It was unintended. Sam On Tue, Aug 25, 2015 at 8:32 AM, stephen sefick ssef

Re: [R] Choosing columns by number

2015-08-25 Thread David Winsemius
On Aug 25, 2015, at 8:17 AM, Sam Albers wrote: Hi all, This is a process question. How do folks efficiently identify column numbers in a dataframe without manually counting them. For example, if I want to choose columns from the iris dataframe I know of two options. I can do this:

[R] Choosing columns by number

2015-08-25 Thread Sam Albers
Hi all, This is a process question. How do folks efficiently identify column numbers in a dataframe without manually counting them. For example, if I want to choose columns from the iris dataframe I know of two options. I can do this: str(iris)'data.frame':150 obs. of 5 variables: $

Re: [R] Choosing columns by number

2015-08-25 Thread stephen sefick
?grep I think this will do what you want. #something like a - data.frame(a=rnorm(10), b=rnorm(10), c=rnorm(10), d=rnorm(10)) toMatch - c(a, d) grep(paste(toMatch,collapse=|), colnames(a)) #to subset a[,grep(paste(toMatch,collapse=|), colnames(a))] On Tue, Aug 25, 2015 at 10:17 AM, Sam

Re: [R] Choosing columns by number

2015-08-25 Thread Marc Schwartz
On Aug 25, 2015, at 10:17 AM, Sam Albers tonightstheni...@gmail.com wrote: Hi all, This is a process question. How do folks efficiently identify column numbers in a dataframe without manually counting them. For example, if I want to choose columns from the iris dataframe I know of two

Re: [R] Choosing columns by number

2015-08-25 Thread K. Elo
Hi! 25.08.2015, 18:17, Sam Albers wrote: Hi all, This is a process question. How do folks efficiently identify column numbers in a dataframe without manually counting them. For example, if I want to choose columns from the iris dataframe I know of two options. I can do this:

Re: [R] Choosing columns by number

2015-08-25 Thread Sam Albers
Thierry's answer of: data.frame( seq_along(iris), colnames(iris) ) is exactly what I was looking for. Apologies for vagueness and HTML. It was unintended. Sam On Tue, Aug 25, 2015 at 8:32 AM, stephen sefick ssef...@gmail.com wrote: ?grep I think this will do what you want. #something