Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)

Let say, for instance, the following code prints 3 large tables that I am unable to assign to an object.

reclassification(data = data, cOutcome = 1, predrisk1 = predictor1, predrisk2 = predictor2, cutoff = seq(0,1,0.1))

I don't think the details are important, but in the interests of making this example reproducible, below are the variables used in the above arguments

data = data.frame(outcome = c(0,0,0,0,1,1,1,1), predictor1 = c(0,1,2,0,1,2,0,0.5), predictor2 = c(0.5,1.5,2,0,0.5,2,0,0.5))

mod1 <- glm(outcome ~ predictor1, data = data, family = binomial(link="logit"))

mod2 <- glm(outcome ~ predictor2, data = data, family = binomial(link="logit"))

predictor1 <- predict(mod1, data, type = "response")

predictor2 <- predict(mod2, data, type = "response")

Is anyone able to explain how I can assign my output to an object, preferably in a neat tabular format that is amenable to further analysis?

1 Answer

0 votes
by (108k points)

In R programming, you can use the capture.output() which will obtain the results as a character vector. Then you can extract the tables from it.

out<- capture.output(reclassification(data = data, cOutcome = 1, predrisk1 = predictor1, predrisk2 = predictor2, cutoff = seq(0,1,0.1)))

Browse Categories

...