Dear R friends:

Can someone help me with the following problem? Many thanks in advance.

# Problem Description:
# I want to write functions which take a (character) vector of dataframe
names as input argument.
# For example, I want to extract the number of observations from a number of
dataframes.
# I tried the following:

nobs.fun <- function (dframe.vec)
{
  nobs.vec <- array(NA,c(length(dframe.vec),1))

  for (i in 1:length(dframe.vec))
      {
      nobs.vec[i] <- dim(dframe.vec[i])[1]
      }

  return(nobs.vec)
}

# To show the problem, I create a fake dataframe and store its name (i.e.,
dframe.1)
# in a vector (i.e., dframe.vec) of length 1.

# creation of fake dataframe
dframe.1 <- as.data.frame(matrix(seq(1:2),c(1,2)))
# store the dataframe name into a vector using c() function
dframe.vec <- c("dframe.1")

# The problem is that the following line does not work
nobs.fun(dframe.vec)

# Seems to me, the problem stems from the fact that dframe.vec[1] is
intepreted by R as "dframe.vec" (note: it is quotated)
# and dim("dframe.vec")[1] gives NULL.
# Also, I realize the following line works as expected (note: dframe.1 is
not quoted any more):
dim(dframe.1)[1]

So my question is then: how can I pass dataframe names as an input argument
for another function
without running into the quotation mark issue above?

Any hint?

Thank you in advance.
-Sean

	[[alternative HTML version deleted]]

