get name for use in coxph in R language -
I have more than 100 metabolites and some confidential datasets like age, gender, BMI. Now I want to test each single metabolites together with sophists with coxph in a for loop.
My problem is the formula and I feel like how can I include metabolite names in the formula? Here is an example code: The result is: If I do this more than 100 times then I Can not differentiate between I thought it might be cleaner, but it's about the same < Pre> Here I use Where received () works but gives me expression only
get (x) . When I only use X, I got an error message
"Variable lengths differ" .
x
rho chisq p get (x) -0.06279 6.22e-01 0.4302 SEX-0.07272 7.5 9-01 0.3838 Age -0.02007 6.01e-02 0.8064 BMI 0.01479 3.02e-02 0.8620
get (x) in the result file
#sample data dd & lt; -data.frame (a = 1: 10, b = rnorm (10), c = runif (10), y = rpois (10,5)) #get column as the proper "name" element of the x < - lapply (for names (dd) [- ncol], as.name # formula lapply (x, function (v) lm (bquote (y. (V)), dd to include names in # Use Cloth.
lm to create a run-worthy example This should be similar to any model that uses a formula Your call looks more
coxph (bquote (surv (age, fup_alter, hyper) ~. (X) + age + SEX + BMI), data = data,)
bquote surrounds the entire formula and then Use
. (X) to enter "name" elemennt in the form. In my example, there is a list of
x , so let me call it
lapply Need to do it again.
Comments
Post a Comment