findMax <- function(x,y){
np = length(x)
ix = which.max(y)
ixx = min(np-1,max(2,ix))
tx = x[ixx + c(-1,0,1)]
ty = y[ixx + c(-1,0,1)]
co = coef(lm(ty ~ tx + I(tx^2)))
xmax = co[2] /(-2 * co[3])
ymax = co %*% (xmax^(0:2))
return(c(xmax,ymax))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.