[R] Dataframes in PLS package
b.h.mevik at usit.uio.no
Tue Feb 21 15:54:08 CET 2012
westland <westland at uic.edu> writes:
> Here is what I have done:
> I read in an 10000 x 8 table of data, and assign the first four columns to
> matrix A and the second four to matrix B
> pls <- read.table("C:/Users/Chris/Desktop/SEM Book/SEM Stat
> Example/Simple Header Data for SEM.csv", header=TRUE, sep=",",
> na.strings="NA", dec=".", strip.white=TRUE)
The problem is here:
> A <- c(pls,pls,pls,pls)
> B <- c(pls,pls,pls,pls)
This creates lists A and B, not data frames.
Either use cbind() instead of c(), or simply say
A <- pls[,1:4]
B <- pls[,5:8]
The the rest should work.
Btw. it is probably a good idea to avoid single-character names for
variables. Especially c and C, because they are names of functions in R.
More information about the R-help