Thanks Don
Please forgive my poor mail-liost etiquette.
I had a couple of errors:
1) the counter logic in the loop was "i in name list", my typo in the post.
2) There were typos in the variable list that caused the loop to crash when
they were encountered.
Thanks for your help, really apprecia
The select argument to subset() is supposed to name the columns you want
to keep.
So is the syntax I gave, table[,list1], and it is the correct way when
list1 is a character vector (which it is).
Your error message says that at least one of the values in list1 is not
the name of a column in your d
Thanks Don
but
table[,list1]
did not work either:
Error in `[.data.frame`(table, , list1) : undefined columns selected.
I'm guessing my list (list1) is not structured right? Displaying it has no
commas, so the whole list may be taken as a single variable rather than a
sequence of variables? I
Instead of
subset(table, select=list1)
try
table[, list1]
However, I suspect you have other problems.
Particularly, i is not defined when you use i %in% namelist.
You may have wanted
i in namelist
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermo
Hi there, I would like to use a list variable to select columns in a subset
from a parent table:
I have a data frame "table" with column headers a,b,c,d,e,x,y,z
and list variables
list1=c("a","b","c","d")
list2=c("a","b","x",y","z")
namelist=c("peter","paul","mary","jane")
group1=c("peter","paul
5 matches
Mail list logo