Emma Jones <evjo...@ualberta.ca> writes:

> My current data structure consists of a .csv
> file read into R containing 15 columns (a charcoal dilution series going
>>From 100% to 0%) and 1050 rows of absorbance data from 400 nm to 2500 nm at
>  2 nm interval. I think I need to transpose the data such that the specific
> wavelengths become my columns and dilutions are defined in rows,

Yes, you need to transpose the data so a coloumn corresponds to a
variable (response or predictor).

> Should I (and how do I) make my absorbance data into
> individual matrices that read into a data frame with only two columns

It is best to put all predictors (wavelengths) together in one matrix,
yes.  The same for the responses, if you have more than one response
coloumn.

This is untested, so there might be errors:

Assuming that your spectroscopic data is read into a data frame called
origspec:

## This should create a matrix with the wavelengths as coloumns:
spec <- t(as.matrix(origspec))

I don't know what your response is, so I'm just assuming it is in a
vector called resp.

# This would create a data frame suitable for plsr():
mydata <- data.frame(resp = resp, spec = I(spec))

Then you can analyse like this:

plsr(resp ~ spec, data = mydata, ....)

-- 
Bjørn-Helge Mevik

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

Reply via email to