Re: [R] Coercing a list of variables in a function call

2008-12-01 Thread Dimitris Rizopoulos
try the following: model.it <- function (form, data, factor.id) { if (!missing(factor.id) && all(factor.id %in% names(data))) data[factor.id] <- lapply(data[factor.id], factor) glm(form, data = data) } y <- c(1,2.1,3.3,4.3,5,6.5) x1 <- c(1,1,1,2,2,2) x2 <- c(1,2,3,1,2,3) x3 <- c(

[R] Coercing a list of variables in a function call

2008-12-01 Thread Philip Whittall
This is hopefully a trivial problem for list subscribers, but I am very new to writing R functions. I wish to call an R function written by myself from another program to fit a model. I need to tell it which of the independent variables are factors. I need to do this in a generic way, so that when