Apologies, but all that ifelse() stuff is too hard to follow.
What I would do is compute a character vector of column names to keep,
then do
a1[ , names.to.keep]
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 1/10/1
Dear Rxperts...
I would like to conditionally include an element (as a column) in a
dataframe. Please see the sample code below:
There is a correction to the earlier post.. my apologies...
a1 <- data.frame(P=rep(1,10),Qr=LETTERS[1:10],b=letters[1:10],
R=rep(c("A","B"),each=5))
lc1 <- list(C1 =
Dear Rxperts...
I would like to conditionally include an element (as a column) in a
dataframe. Please see the sample code below:
a1 <-
data.frame(P=rep(1,10),Qr=LETTERS[1:10],b=letters[1:10],R=rep(c("A","B"),each=5))
lc1 <- list(C1 = "P",C2 =
ifelse(is.element("Q",names(a1)),"Q",ifelse(is.elem
3 matches
Mail list logo