[R] Selecting with mouse the lines drawn by matplot()

servet cizmeli sa.cizmeli at usherbrooke.ca
Fri May 25 22:52:43 CEST 2012


Dear all,

I have a dataset of spectral measurements of sunlight. One row for each 
different observation, one column for each spectral channel.

I would like to select the spectral curves drawn with matplot() (I only 
know matplot() as a way of easily drawing them) with the help of the 
mouse and extract their row indexes  :

a=url("http://ekumen.homelinux.net/spectra.RData")
load(a)
matplot(lbd2, t(mySpectra), type="l",xlab="Wavelength [nm]",ylab="Radiance")

I was hoping that identify() would work on such a graphic but 
unfortunately it does not. I tried to the "identify" function of the 
package playwith(), but still the same problem.

I think I will have to write a function that does the job. But before 
that, I would like to have your opinions. What would be the easiest way 
of accomplishing this task?

Thank you very much
Best regards
servet



More information about the R-help mailing list