Reputation: 195
I am trying to do a Principal Component Regression using the pls
library and I've tried to store the summary output into a variable c
with no success. This is an example of my code
library (pls)
b <- pcr(perm ~ area + peri + shape, data = rock, validation = "CV")
c <- summary(b)
c
NULL
What I want is to store the summary output of the pcr model into a variable so I can access to it later. Any hint to make this work will be deeply apreciated
Upvotes: 2
Views: 313
Reputation: 1094
I think you need capture.output()
. I remember using it some time back learning it from one of the stackoverflow threads itself:
library (pls)
b <- pcr(perm ~ area + peri + shape, data = rock, validation = "CV")
x<-(capture.output(summary(b)))
x
Result:
> x
[1] "Data: \tX dimension: 48 3 " "\tY dimension: 48 1"
[3] "Fit method: svdpc" "Number of components considered: 3"
[5] "" "VALIDATION: RMSEP"
[7] "Cross-validated using 10 random segments." " (Intercept) 1 comps 2 comps 3 comps"
[9] "CV 442.5 394.7 271.2 293.9" "adjCV 442.5 393.9 269.8 290.7"
[11] "" "TRAINING: % variance explained"
[13] " 1 comps 2 comps 3 comps" "X 94.07 100.00 100.00"
[15] "perm 23.01 68.33 70.44"
Upvotes: 2