# \donttest{
require(ggplot2)
set.seed(1234)
x <- seq(0, 3, length.out = 100)
y <- harm1(x, 0, 0, 0.05, 0) + rnorm(length(x), 0, 0.002)
dat <- data.frame(x = x, y = y)
fit <- nls(y ~ SSharm1(x, b0, b1, cos1, sin1), data = dat)
## plot
ggplot(data = dat, aes(x = x, y = y)) +
geom_point() +
geom_line(aes(y = fitted(fit)))
# }
Run the code above in your browser using DataLab