I write the next for loop-
df_total<-data.frame()
**for (i in unique(danadata$product))
{
maindatatest <- danadata %>% filter(product %in% i )
print(i)
df <- synth.func(maindatatest)
df_total<-rbind(df_total,df)
}**
Everything works fine, until I get the next error-
> Error in svd(c) : infinite or missing values in 'x'
I do not fully understand what is causing the problem because I run on the same problem i separately the function it works. Anyway, I want to skip the error and the loop will continue to work. I realized I should add something that looks like this -
for (i in 1:10) {
skip_to_next <- FALSE
# Note that print(b) fails since b doesn't exist
tryCatch(print(b), error = function(e) { skip_to_next <- TRUE})
if(skip_to_next) { next }
}
I can't integrate the solution to the original loop error above, I'd love for help. In addition, I want to get a list of those i that caused the problem so I will deal with them separately.
Thanks!