[R] Average of several line plots

Petr PIKAL petr.pikal at precheza.cz
Thu Feb 3 10:56:13 CET 2011


Hi

r-help-bounces at r-project.org napsal dne 03.02.2011 10:36:57:

> 
> Hi,
> 
> Peter: thank you, I have taken a look at ?approxfun but I'm not sure it 
does
> what I'm after.

Hm, maybe yes. But not approxfun but approx

x1<-1:15
x2<-50:100
y1<-rnorm(15)
y2<-rnorm(51)
yy2<-approx(x2,y2)$y
yy1<-approx(x1,y1)$y
plot(1:50,yy1)
points(1:50,yy2, col=2)
 
Regards
Petr


> 
> Eduardo:
> 
> The data doesn't represent functions. Basically the X values represent 
the
> distance across a sample and the Y values are a measure of the colour
> intensity at that point across the sample (i.e. a line plot across the
> sample). Each data set represents a measurement across a different 
section
> of the sample. All data sets show alternating 'light' and 'dark' 
sections,
> though the sample isn't perfect so the widths of each section do not
> entirely match up from one data set to another. 
> 
> The problem comes from the fact that some data sets contain as many as 
400
> measurements across the sample whereas others contain as few as 150
> measurements. This means that measurements do not necessarily occur at 
the
> same value of X on different data sets. Therefore I think I need some 
way to
> average the lines ('of best fit') that each data set creates on the 
graph,
> rather than averaging the data ponits themselfs as I can't see how I can
> take averages/weighted averages of the data points when they occur at
> different values of X (and at different intervals) across the sample. Is 
my
> description any better this time?
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Average-of-
> several-line-plots-tp3254850p3257696.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list