I am trying to run some trading strategies in R. I have downloaded some stock prices and calculated returns. The new return dataset has a number of -inf, NaN, and NA values.
Using mutate_all in dplyr:
library(dplyr) fortify.zoo(log_ret) %>% mutate_all(function(x) ifelse(is.infinite(x), 0, x))