You could use a slider to move along the x-axis looking at your data in the specified window width. Below is an example with some fake data.
library(rpanel) # some fake data myx <- 623+1:1000 myy <- 0.01*myx + rnorm(1000) # width of viewing window mywindow <- 256 # plot the data with a slider for the viewing window if (interactive()) { viewslice <- function(panel) { # the viewing window is defined by this slice of the x-axis xslice <- panel$start+c(0, panel$window) # optional: redefine the range of the y-axis depending on the xslice yrange <- range(panel$y[panel$x >= xslice[1] & panel$x <= xslice[2]]) plot(panel$x, panel$y, xlim=panel$start+c(0, panel$window), ylim=yrange) panel } panel <- rp.control(x=myx, y=myy, start=1, window=mywindow) rp.slider(panel, start, min(myx), max(myx)-mywindow, showvalue=TRUE, action=viewslice) } Jean On Tue, Nov 12, 2013 at 8:59 AM, Baro <babak...@gmail.com> wrote: > I would like to have a relative x-axis in r. I am reading time seris from > an excel file and I want to show in a plot and also I want to have a window > which moves over the values. > > My aim ist to see which point belongs to which time(row number in excel > file). i.e I am reading from 401th row in 1100th column in excel file and > my window length is 256. here is my code: > > #which column in excel filespalte<-1100 > #start row and end row > start<-401end<-600 > > window<-256 > n<-1 > > wb <- loadWorkbook("D:\\MA\\excel_mix_1100.xls") > dat <-readWorksheet(wb, sheet=getSheets(wb)[1], startRow=start, > endRow=end, startCol=spalte, endCol=spalte,header=FALSE) > datalist<-dat[seq(1, length(dat[,1]), by = 2),] > datalist<-matrix(datalist)while(1+window<=length(datalist)){ > kd<-matrix(as.integer(datalist[n:(n+window-1),1])) > Sys.sleep(0.2) > > plot(kd,type="l",col="blue",xlab="Rohdaten",ylab="values",xlim=c(start+n,start+n+window-1)) > n<-n+1} > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.