## load library
library("MALDIquant");
## create a MassPeaks object from scratch
p <- createMassPeaks(mass=1:20, intensity=sample(x=100:10000, size=20),
metaData=list(name="example"));
## plot peaks
plot(p);
## label the first 5 peaks
labelPeaks(p, index=1:5);
## label all peaks in mass range 15 to 20
labelPeaks(p, mass=15:20, underline=FALSE);
## label highest peaks (top 5)
top5 <- intensity(p) %in% sort(intensity(p), decreasing=TRUE)[1:5];
labelPeaks(p, index=top5, col="red");Run the code above in your browser using DataLab