There are functions which use variable names as parameters in some R packages. However, if the variable name is stored in another variable, how can I pass this variable to the function. Taking the "rms" package as an example:
library(rms) n <- 1000 age <- rnorm(n, 50, 10) sex <- factor(sample(c('female','male'), n,TRUE)) y <- rnorm(n, 200, 25) ddist <- datadist(age, sex) options(datadist='ddist') fit <- lrm(y ~ age) Predict(fit, age, np=4) options(datadist=NULL) Here "age" was a variable name passed to Predict() function, but if "age" was stored in variable "var", that is, var <- "age", how can I pass "var" to Predict() function? The purpose is that I want to change the parameter of Predict() in a loop. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.