[R] Howto access V-base only column in a data frame
m_olshansky at yahoo.com
Fri Jun 20 06:07:50 CEST 2008
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)
(where df is your dataframe).
P.S. I won't be surprised if df[,goodNames] is all right too (have not checked).
--- On Fri, 20/6/08, Gundala Viswanath <gundalav at gmail.com> wrote:
> From: Gundala Viswanath <gundalav at gmail.com>
> Subject: [R] Howto access V-base only column in a data frame
> To: r-help at stat.math.ethz.ch
> Received: Friday, 20 June, 2008, 1:27 PM
> Suppose I have the following data frame:
> V1 V2 V3 var
> 1 100 200 400 2.3
> 2 40.5 1.2 20.3
> In this example the maximum V column is 3.
> In my code there the column number can be varied.
> My question is how can I access data frame
> from column V1 up to Vk (some "k" and
> excluding'var' column)?
> - Gundala Viswanath
> Jakarta - Indonesia
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained,
> reproducible code.
More information about the R-help