I would like to play with the plumber
library by making an app that takes 14 days of historical data and returns an exponential smoothing forecast.
The problem is I am somewhat unfamiliar with passing a lot of data (a parameter with multiple values) to an API. My questions can be summarized as follows:
How should I prepare the data in R to be passed to the API?
How should the API be prepared in
plumber
to receive time series data?
Below is some example data and a function which accomplishes what I would like in R.
library(tidyverse)
# data to be passed to API
head(forecast::wineind,14)
#> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
#> 1980 15136 16733 20016 17708 18019 19227 22893 23739 21133 22591 26786
#> 1981 15028 17977
#> Dec
#> 1980 29740
#> 1981
#* Return Forecast Data
#* @list a The first number
#* @get /simple_fcast
function(){
ts() %>%
forecast::ets() %>%
forecast::forecast()
}
#> function(){
#> ts() %>%
#> forecast::ets() %>%
#> forecast::forecast()
#> }
Created on 2018-11-14 by the reprex package (v0.2.1)