[R] Interactive plots with R

From: Andris Jankevics <andza_at_osi.lv>
Date: Wed 31 Jan 2007 - 11:50:30 GMT


Hi,

I wrote some simple rpanel package script for visual spectral data comparison. At this example i have a three samples and i want to zoom through x and y axis to compare differences between samples. With my script below I can zoom to some data region and add some other spetra to the plot, through text input field.
But I can't figure out, how to change axis scaling for all displayed spectra, because only first spectra are redrawed after axis scaling. Or maybe I need to study samples and documentation for tcltk package?

My script:

DATAPPM=seq(0,11,0.004)
DATAPPM=data.frame(DATAPPM,DATAPPM,DATAPPM) DATAS=data.frame
(S1=sample(1:3260,2751),S2=sample(1:3260,2751),S3=sample(1:3260,2751))

library (rpanel)
pplotNMR <- function (panel) {

	with (panel,{
	VECP <- DATAPPM[,sample]
	VECS <- DATAS[,sample]	
	names (VECP) <- rownames(DATAPPM)
	names (VECS) <- rownames(DATAS)
	SEL <- names(VECP[VECP>MIN & VECP<MAX])
	VECP <- VECP[SEL]
	VECS <- VECS[SEL]
	plot (VECP,VECS,type="l",xlim=c(MAX,MIN),xlab="PPM",ylab="intensity",
	ylim=c(YMIN,YMAX))
	panel})

}
pplotNMRadd<- function (panel) { with (panel, { sample <- as.numeric (sample.text) VECP <- DATAPPM[,sample] VECS <- DATAS[,sample] names (VECP) <- rownames(DATAPPM) names (VECS) <- rownames(DATAS) SEL <- names(VECP[VECP>MIN & VECP<MAX]) VECP <- VECP[SEL] VECS <- VECS[SEL] points (VECP,VECS,type="l",col=sample) panel })
}

panel <- rp.control (title="NMR
control",MIN=-2,MAX=12,sample=1,YMAX=max(apply(DATAS,2,max)),YMIN=min(apply(DATAS,2,min)),sample.text=1) rp.slider(panel,MIN,from=-2,to=12,showvalue=TRUE,action=pplotNMR,title="ppm min")
rp.slider(panel,MAX,from=-2,to=12,showvalue=TRUE,action=pplotNMR,title="ppm max")
rp.slider(panel,YMAX,from=YMIN,to=max(apply(DATAS,2,max)),showvalue=TRUE,action=pplotNMR,title="Intesity") rp.doublebutton (panel,YMAX,step=10,action=pplotNMR,title="intensity, step=10",showvalue=TRUE)
rp.textentry (panel, sample.text, action=pplotNMRadd, title="Add sample to plot:")

Thanks and regards,
Andris Jankevics



R-help@stat.math.ethz.ch 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. Received on Wed Jan 31 22:55:35 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 31 Jan 2007 - 12:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.