so let's have named vector: sorted = c(1,2,3) names(sorted) = c("a","b","c") and it'll following: > sorted b c 1 2 3 so vector named a,b,c, , has value 1,2,3 respectively. and have sample data: data.ex = as.data.frame(matrix(rep(c(1,2,3,4),3), nrow = 3, ncol = 3)) colnames(data.ex) = c("a","b","c") so data frame has 3 columns named a,b,c well. i want predict c using value in glm(): fit.ex = glm(formula = c ~ names(sorted)[2], data = data.ex, family = binomial(link = "logit")) but then, i'll keep getting following error message: error in model.frame.default(formula = c ~ names(sorted)[2], data = data.ex,: variable lengths differ (found 'names(sorted)[2]') i read article here , found as.name() function, still not working: http://www.ats.ucla.edu/stat/r/pages/looping_strings.htm and cannot find else thats similar problem. please, if the...
Comments
Post a Comment