Re: [R] PLSR error

2011-05-14 Thread Uwe Ligges



On 13.05.2011 11:38, romzero wrote:

Hi,
this is my R-Script

library(pls)
file<- "C:\\TXT\\brix.txt"
d<- as.matrix(read.table(file, header=T, sep=",", row.names = NULL))
plsdata<- data.frame(NIR=c(1:nrow(X)))
plsdata$NIR<- I(d[,3:603])
plsdata$Brix<- d[,2]
results<- plsr(Brix ~ NIR, data=plsdata)

after the last string i have this error


results<- plsr(Brix ~ NIR, data=plsdata)

Error in `[[<-.data.frame`(`*tmp*`, i, value = c(302053L, 305882L, 292704L,
:
   replacement has 448346 rows, data has 746
In addition: Warning message:
In model.matrix.default(mt, mf) : variable 'Brix' converted to a factor

the data table have this structure

str(plsdata)

'data.frame':   746 obs. of  2 variables:
  $ NIR : 'AsIs' chr [1:746, 1:601] "0.0011030396" "0.0013019324"
"0.0005979965" "0.0012952804" ...
   ..- attr(*, "dimnames")=List of 2
   .. ..$ : NULL
   .. ..$ : chr  "X1100.0" "X1102.0" "X1104.0" "X1106.0" ...
  $ Brix: chr  "24.4" "24.8" "24.7" "20.1" ...



All your data are character rather than numeric. If you fo not transform 
the data.frame to a matrix at the very beginning after reading the 
data.frame, things should be fine, I guess (untested, since we do not 
have the data).


Uwe Ligges



where am I wrong?
thanks for help


--
View this message in context: 
http://r.789695.n4.nabble.com/PLSR-error-tp3519805p3519805.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


__
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.


[R] PLSR error

2011-05-13 Thread romzero
Hi,
this is my R-Script

library(pls)
file <- "C:\\TXT\\brix.txt"
d <- as.matrix(read.table(file, header=T, sep=",", row.names = NULL))
plsdata <- data.frame(NIR=c(1:nrow(X)))
plsdata$NIR <- I(d[,3:603])
plsdata$Brix <- d[,2]
results <- plsr(Brix ~ NIR, data=plsdata)

after the last string i have this error

> results <- plsr(Brix ~ NIR, data=plsdata)
Error in `[[<-.data.frame`(`*tmp*`, i, value = c(302053L, 305882L, 292704L, 
: 
  replacement has 448346 rows, data has 746
In addition: Warning message:
In model.matrix.default(mt, mf) : variable 'Brix' converted to a factor

the data table have this structure
> str(plsdata)
'data.frame':   746 obs. of  2 variables:
 $ NIR : 'AsIs' chr [1:746, 1:601] "0.0011030396" "0.0013019324"
"0.0005979965" "0.0012952804" ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr  "X1100.0" "X1102.0" "X1104.0" "X1106.0" ...
 $ Brix: chr  "24.4" "24.8" "24.7" "20.1" ...

where am I wrong?
thanks for help


--
View this message in context: 
http://r.789695.n4.nabble.com/PLSR-error-tp3519805p3519805.html
Sent from the R help mailing list archive at Nabble.com.

__
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.