Please ask your questions about R Markdown here.
Hi, I have been trying to generate 2 tables and I can only generate 1 of them as seen in the screenshot
Below are the codes that I have done to try generate the tables
stocks<-c("HD", "IP","RAD")%>%
tq_get(get = "stock.prices", from = "2000-01-01")%>%
select(symbol, date, adjusted)
head(stocks, n=6)%>%
kable(caption = "First 6 Rows of Adjusted Stock Price from 1 January 2000.")
stocks=stocks%>%
mutate(event=ifelse(date == "2008-09-15", "Lehman Bankruptcy",
ifelse(date == "2020-03-01", "Pandemic", "BAU")))
head(stocks, n=6)%>%
kable(caption = "First 6 Rows of Adjusted Stock Price from 1 January 2000.")
stocks%>%
group_by(symbol) %>%
summarise(`regress coefficient of date` =lm(adjusted ~ date)$
coefficients[2],`residual of Bankruptcy` =
abs(lm(adjusted ~ date)$residuals[event == "Leham Bankruptcy"]),
`residual of Pandemic` =
abs(lm(adjusted ~ date)$
residuals[event == "Pandemic"]),
`residual of BAU` = mean(abs(lm(adjusted ~ date)$
residuals[event == "BAU"])), )
Any suggestions will be highly appreciated. Thanks!