I am getting the following error message from the code below:
In to_period(xx, period = on.opts[[period]], ...) :
missing values removed from data*
It works with some stocks, but some get the same error message as this one. Should I just use na.omit(N225) before tq_transmute?
N225 <- tq_get("^N225",
from = "2016-01-01",
to = "2020-12-31",
get = "stock.prices")
N225_monthly_returns <- N225 %>%
tq_transmute(select = adjusted,
mutate_fun = periodReturn,
period = "monthly",
col_rename = "n225_returns")
Using
na.omit
drops theNA
rows and doesn't give any warnings. It also gives the same output as the one without usingna.omit
so we don't loose any rows.