data(tecator)
splom(~endpoints)
# plot 10 random spectra
set.seed(1)
inSubset <- sample(1:dim(endpoints)[1], 10)
absorpSubset <- absorp[inSubset,]
endpointSubset <- endpoints[inSubset, 3]
newOrder <- order(absorpSubset[,1])
absorpSubset <- absorpSubset[newOrder,]
endpointSubset <- endpointSubset[newOrder]
plotColors <- rainbow(10)
plot(absorpSubset[1,],
type = "n",
ylim = range(absorpSubset),
xlim = c(0, 105),
xlab = "Wavelength Index",
ylab = "Absorption")
for(i in 1:10)
{
points(absorpSubset[i,], type = "l", col = plotColors[i], lwd = 2)
text(105, absorpSubset[i,100], endpointSubset[i], col = plotColors[i])
}
title("Predictor Profiles for 10 Random Samples")
Run the code above in your browser using DataLab