The following is a bug or feature in recent versions. Try the
following with a clean workspace:

y <- cbind(rpois(20,4),rpois(20,4))
df <- data.frame(y=y,x=rnorm(20))
colnames(df)
colnames(model.frame(y~x,data=df))

Now start over with a clean workspace and try

df <- data.frame(y=cbind(rpois(20,4),rpois(20,4)),x=rnorm(20))
model.frame(y~x,data=df)
glm(y~x,data=df,family=binomial)

I have hacked a fix, given in the patch below. It works for me but may
break other code. I avoid data.frames like the plague so have little
to test it on. I had to use them in glmm to communicate with glm in
certain contexts but I now think I would have been much better off
rewriting IWLS from scratch.

I think it is extremely dangerous that glm with the data option looks
for variables in the environment if it does not find them in the
dataframe supplied instead of giving an error (although not really my
problem because I never use that option except in glmm).
  Jim

----------------------------------------------------------------------
*** base/R/dataframe.R.old	Tue Jan  5 00:21:23 1999
--- base/R/dataframe.R	Mon Feb  1 17:44:02 1999
***************
*** 218,241 ****
      if(length(vnames) != n)
  	vnames <- character(n)
      no.vn <- nchar(vnames) == 0
!     value <- vnames <- as.list(vnames)
      nrows <- numeric(n)
      for(i in 1:n) {
  	xi <- as.data.frame(x[[i]], optional=TRUE)
  	rowsi <- attr(xi, "row.names")
! 	nnew <- length(xi)
  	namesi <- names(xi)
! 	if(nnew>1) {
! 	    if(length(namesi) == 0) namesi <- seq(length=nnew)
! 	    if(no.vn[i]) vnames[[i]] <- namesi
! 	    else vnames[[i]] <- paste(vnames[[i]], namesi, sep=".")
! 	}
! 	else if(length(namesi) > 0) vnames[[i]] <- namesi
  	else if(no.vn[[i]]) vnames[[i]] <- deparse(object[[i]])[1]
  	nrows[[i]] <- length(rowsi)
  	if(missing(row.names) && rowsi[[1]]!="")
  	    row.names <- data.row.names(row.names, rowsi, i)
! 	value[[i]] <- xi
      }
      nr <- max(nrows)
      for(i in seq(length=n)[nrows < nr]) {
--- 218,251 ----
      if(length(vnames) != n)
  	vnames <- character(n)
      no.vn <- nchar(vnames) == 0
! #    value <- vnames <- as.list(vnames)
!     vnames <- as.list(vnames)
!     value <- list()
      nrows <- numeric(n)
+     k <- 1
      for(i in 1:n) {
  	xi <- as.data.frame(x[[i]], optional=TRUE)
  	rowsi <- attr(xi, "row.names")
! #	nnew <- length(xi)
  	namesi <- names(xi)
! #	if(nnew>1) {
! #	    if(length(namesi) == 0) namesi <- seq(length=nnew)
! #	    if(no.vn[i]) vnames[[i]] <- namesi
! #	    else vnames[[i]] <- paste(vnames[[i]], namesi, sep=".")
! #	}
! #	else if(length(namesi) > 0) vnames[[i]] <- namesi
! 	if(length(namesi) > 0) vnames[[i]] <- namesi
  	else if(no.vn[[i]]) vnames[[i]] <- deparse(object[[i]])[1]
  	nrows[[i]] <- length(rowsi)
  	if(missing(row.names) && rowsi[[1]]!="")
  	    row.names <- data.row.names(row.names, rowsi, i)
! #	value[[i]] <- xi
! 	if(is.data.frame(x[[i]]))for(j in 1:ncol(x[[i]])){
! 		value[[k]] <- x[[i]][,j]
! 		k <- k+1}
! 	else {
! 	     value[[k]] <- x[[i]]
! 	     k <- k+1}
      }
      nr <- max(nrows)
      for(i in seq(length=n)[nrows < nr]) {
***************
*** 245,251 ****
  	else stop(paste("arguments imply differing number of rows:",
  			paste(unique(nrows), collapse = ", ")))
      }
!     value <- unlist(value, recursive=FALSE, use.names=FALSE)
      vnames <- unlist(vnames)
      noname <- nchar(vnames) == 0
      if(any(noname))
--- 255,261 ----
  	else stop(paste("arguments imply differing number of rows:",
  			paste(unique(nrows), collapse = ", ")))
      }
! #    value <- unlist(value, recursive=FALSE, use.names=FALSE)
      vnames <- unlist(vnames)
      noname <- nchar(vnames) == 0
      if(any(noname))
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

