[R] R PLS package data format
Dear sir, If I have a vector as: y - c(1:4) and a matrix as: x - matrix (5:12, nrow=4, ncol=2) Then I create a data frame as: t - data.frame(y, x) R will generate a data frame of 3 columns names(t) y X1 X2 is.vector(t$X1) returns TRUE is.vector(t$X2) returns TRUE R splits the columns of a matrix into column vectors automatically. How should I create a data frame of t$y t$x such that is.vector(t$y) returns TRUE is.matrix(t$x) returns TRUE That is, how to make x column of the data frame a matrix? Just like the test data ¡§gasoline¡¨ in your PLS package: library(pls) data(yarn) is.vector(density) returns TRUE is.matrix(NIR) returns TURE (NIR is a matrix) Best regards, Shaowen Cheng The information in this e-mail may be confidential; it is intended for use solely by the individual or entity named as the recipient hereof. Disclosure, copying, distribution, or use of the contents of this e-mail by persons other than the intended recipient may violate applicable laws and if you have received this e-mail in error, please delete the original message and notify us by collect call immediately. Thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] R PLS package data format
hi, because of my ignorance I can't figure out why would you need such a structure. However the following trick works: a - matrix(1:6,3) b - data.frame(1:3) b$a - a b X1.3 a.1 a.2 11 1 4 22 2 5 33 3 6 names(b) [1] X1.3 a class(b$a) [1] matrix is.matrix(b$a) [1] TRUE hope that's help PF 2011/6/27 新鼎-智慧製造事業處-鄭紹文 shaowench...@acs.com.tw: Dear sir, If I have a vector as: y - c(1:4) and a matrix as: x - matrix (5:12, nrow=4, ncol=2) Then I create a data frame as: t - data.frame(y, x) R will generate a data frame of 3 columns names(t) y X1 X2 is.vector(t$X1) returns TRUE is.vector(t$X2) returns TRUE R splits the columns of a matrix into column vectors automatically. How should I create a data frame of t$y t$x such that is.vector(t$y) returns TRUE is.matrix(t$x) returns TRUE That is, how to make x column of the data frame a matrix? Just like the test data ¨gasoline〃 in your PLS package: library(pls) data(yarn) is.vector(density) returns TRUE is.matrix(NIR) returns TURE (NIR is a matrix) Best regards, Shaowen Cheng The information in this e-mail may be confidential; it is intended for use solely by the individual or entity named as the recipient hereof. Disclosure, copying, distribution, or use of the contents of this e-mail by persons other than the intended recipient may violate applicable laws and if you have received this e-mail in error, please delete the original message and notify us by collect call immediately. Thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. -- +--- | Patrizio Frederic, | http://www.economia.unimore.it/frederic_patrizio/ +--- __ R-help@r-project.org mailing list 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.
Re: [R] R PLS package data format
On 2011-06-27 03:02, 新鼎-智慧製造事業處-鄭紹文 wrote: Dear sir, If I have a vector as: y- c(1:4) and a matrix as: x- matrix (5:12, nrow=4, ncol=2) Then I create a data frame as: t- data.frame(y, x) R will generate a data frame of 3 columns names(t) y X1 X2 is.vector(t$X1) returns TRUE is.vector(t$X2) returns TRUE R splits the columns of a matrix into column vectors automatically. How should I create a data frame of t$y t$x such that is.vector(t$y) returns TRUE is.matrix(t$x) returns TRUE That is, how to make x column of the data frame a matrix? Just like the test data ¡§gasoline¡¨ in your PLS package: library(pls) data(yarn) is.vector(density) returns TRUE is.matrix(NIR) returns TURE (NIR is a matrix) This is all perfectly well described in ?data.frame where you will also find reference to the use of I() to accomplish your goal. Peter Ehlers Best regards, Shaowen Cheng The information in this e-mail may be confidential; it...{{dropped:5}} __ R-help@r-project.org mailing list 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.