[R] Gasoline Data in pls package

Bjørn-Helge Mevik b.h.mevik at usit.uio.no
Wed May 12 10:22:31 CEST 2010


Ravi Ramaswamy <raramasw at gmail.com> writes:

> I am using pls package for some pcr computations. There is a data set called
> gasoline.
>
> Would someone be able to tell me what command(s) could be used to produce
> this graph in R?

I presume you are talking about Figure 1 in the pls article in R news
2006/3 [1].  The plot was produced with the following commands:

data(gasoline)
par(mar = c(2, 4, 1, 0) + 0.1)
matplot(t(gasoline$NIR), type = "l", ylab = "log(1/R)", xaxt = "n")
ind <- pretty(seq(from = 900, to = 1700, by = 2))
ind <- ind[ind >= 900 & ind <= 1700]
ind <- (ind - 898) / 2
axis(1, ind, colnames(gasoline$NIR)[ind])

> I am not sure where the log(1/R) - Y-axis - are coming from

The measurements in the NIR matrix are log(1 / reflectance), hence the
label "log(1/R)".  This is how the data was published by Kalivas [2],
and is a standard way of representing Near Infrared Reflectance
measurements.

[1] http://cran.r-project.org/doc/Rnews/Rnews_2006-3.pdf
[2] J. H. Kalivas. Two data sets of near infrared spectra.  Chemometrics and
Intelligent Laboratory Systems, 37: 255–259, 1997.

-- 
Regards,
Bjørn-Helge Mevik



More information about the R-help mailing list