Turn this file into an interactive document with Shiny components. To do this:
"M"
and "F"
name
v. input$name
v. names()
)reactive()
render*()
observeEvent()
eventReactive()
renderDygraph
from the dygraphs package to render your dygraph plotlibrary(reportsWS) library(forecast) library(dygraphs) # SELECT A NAME # SELECT A SEX ("M" or "F") # names <- get_babyname(name, sex) # Create time series and forecast #nbirths <- ts(#names$n, start = 1880) #mod <- auto.arima(#nbirths) #pred <- forecast(#mod, h = 12) # 12 for 2025
Since 1880, r #sum(#nbirths, na.rm = TRUE)
children have been named r #name
. The graph below breaks this number down by year showing the number of children named r #name
as a time series.
# title <- paste0("Number of children named ", #name) # all <- bind_as_xts(#nbirths, #pred) # dygraph(all, main = title) %>% # dySeries("x", label = "n children") %>% # dySeries(c("lower", "fitted", "upper"), label = "Predicted") %>% # dyRangeSelector()
We modeled this time series with an r #trim_whitespace(#pred$method)
model to predict the number of children that will be given the name r #name
in 2025.
# data.frame( # method = trim_whitespace(#pred$method), # predicted_2025 = round(xts::last(#pred$mean)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.