Dear R-users,
-I am new to R, and I am struggling with the following problem.

-I am repeating the following  operations hundreds of times, within a loop:
I want to subset a data frame by columns. I am interested in the columns
names that are given by the rows of another data frame that was built in
parallel. The solution I have so far works well as long as the elements of
the second data frame are included in the column names of the first data
frame but if an element from the second object is not a column name of the
first one, then it bugs.


-More concretely, I have the following data frames d and v:
yyyymmdd<-c("19720601", "19720602", "19720605")
sret.10006<-c(1,2,3)
sret.10014<-c(5,9,7)
sret.10065<-c(10,2,11)


d<- data.frame(yyyymmdd=yyyymmdd, sret.10006=sret.10006,
sret.10014=sret.10014, sret.10065=sret.10065)

v<- data.frame(V1="sret.10006", V2="sret.10090")
v<- sapply(v, function(x) levels(x)[x])

-I want to do the following subsetting:
sub<- subset(d, select=c(v))


and I get the following error message:
Error in `[.data.frame`(x, r, vars, drop = drop) :
  undefined columns selected



Any help would be very much appreciated,

Best,
Aurelien

	[[alternative HTML version deleted]]

