For the mean() example, I believe this should work (untested)
for (var in names(Dataset)) print( mean( Dataset[[var]] , na.rm=TRUE ) )
or
for (var in names(Dataset)) print( mean( Dataset[,var] , na.rm=TRUE ) )
But it's harder with lm, glm, and friends. For them I think maybe you
can do i
Hi,
perhaps that is what you want?
> df <- as.data.frame(matrix(runif(100),ncol=10))
> form <- as.formula(paste(names(df)[length(df)], "~ ."))
> lm(form,data=df)
Call:
lm(formula = form, data = df)
Coefficients:
(Intercept) V1 V2 V3 V4
-1.367 -
Hi!
I have a dataset with some 300+ variables and 2000+ records. I'd like to grind
through a bunch of analyses on the variables by using a script, but can't
figure out how to refer to variable names properly. For some of the simpler
stuff I use various "apply" functions, but for others (like t-tes
3 matches
Mail list logo