[R] Help in using PCR

Bjørn-Helge Mevik b.h.mevik at usit.uio.no
Wed Jul 2 13:39:30 CEST 2008


Gavin Simpson <gavin.simpson at ucl.ac.uk> writes:

>> df <- data.frame(resp = dat[,1], VARS = I(as.matrix(dat[, 2:101])))
>> class(df$VARS)
> [1] "AsIs"
>
> The class is AsIs for $VARS. But if I look at your yarn data set for
> example, the NIR component is of class "matrix":
>
>> class(yarn$NIR)
> [1] "matrix"
>
> How did you achieve this?

I don't remember exactly what I did, but this will work, at least:

yarn <- data.frame(density = ..., train = ...)
yarn$NIR <- as.matrix(...)

For practical purposes, I haven't found any difference between having
the matrices with class "AsIs" and "matrix".

-- 
Bjørn-Helge Mevik



More information about the R-help mailing list