[R] Howto access V-base only column in a data frame
Rolf Turner
r.turner at auckland.ac.nz
Fri Jun 20 06:28:33 CEST 2008
On 20/06/2008, at 4:07 PM, Moshe Olshansky wrote:
> If you know the value of k then you could do the following:
>
> goodNames <- paste("V",1:k,sep="")
> ind <- which(colnames(df) %in% goodNames)
> df[,ind]
>
> (where df is your dataframe).
>
> P.S. I won't be surprised if df[,goodNames] is all right too (have
> not checked).
What about df[,grep("^V",names(df))] ? (Leave off the ``^'' if you
want any
column whose name contains ``V'' (r.t. begins with ``V'').
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list