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 /
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
-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
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:
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:
$
?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
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
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:
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
9 matches
Mail list logo