# NOT RUN {
require(ggplot2)
#Find length of the half waves
x <- seq(0,pi,0.01)
y <- sin(x^2*pi)
qplot(x,y)
#zero method predicting zeros
w.z <- halfwave(x,y,method="zeros",fit=TRUE,smoothing="spline")
#plot waveform with detected half waves using fitted 'zeros' method
p <- ggplot()+geom_point(aes(x=x,y=y))
p <- p+geom_line(data=w.z$names,aes(x=x,y=y,col=wave),alpha=0.4,size=3,inherit.aes=FALSE)
p+theme_classic()
#plot lambda as it varies with position
qplot(data=w.z$dat,x=pos1,y=l)
#peak-to-trough method
w.p <- halfwave(x,y,method="p2t")
qplot(data=w.p$names,x=x,y=y,col=wave)
# }
Run the code above in your browser using DataLab