For the follwing example
n=68
dat <- data.frame(group=rep(LETTERS[1:2], n/2),
x=rnorm(n, 0.1,0.1))
I am trying to run a function (FitDoubleLogBeck
from greenbrown
) by group:
SNDVI0= dat %>%
group_by(group) %>%
dplyr::summarise(smoothNDVI= FitDoubleLogBeck(x, tout = F, weighting = T,
hessian = F, plot = F, ninit = 10)$predicted)
But I got this erro
Error in `dplyr::summarise()`:
! Problem while computing `smoothNDVI = ...$predicted`.
i The error occurred in group 2: group = "B".
Caused by error in `rbind.zoo()`:
! indexes overlap
When I run the function for each group separately it work fine
dat0= subset(dat,group== "A" )
fit <- FitDoubleLogBeck(dat0$x, out = F, weighting = T,
hessian = F, plot = F, ninit = 10)$predicted)
fit$predicted
How I can run the function by grup using dplyr? The original data has more than 6000 group and each group has 52 observations.