You’ve built a great model
You want others to be able to use it
… without R
Application Programming Interface
Standardised way for computers to communicate
Can be called anywhere from internet access
Make your R code more accessible
Allows real time interactivity with other technologies
Increases the impact of an analysis
Easy to scale the reach of your work
The {plumber} package turns functions into API endpoints
```{r}
library(plumber)
#* Predict the weight of the lemur (kg) given it's age (months)
#* @get /
lemur_weight = function(age){
lemurs <- readr::read_csv("lemurs.csv")
fit <- lm(weight_g ~ age_at_wt_mo, data = lemurs)
new <- data.frame(age_at_wt_mo = as.numeric(age))
weight <- predict.lm(fit, newdata = new)/1000
return(weight)
}
```
Run API button
Generates a user interface
Query it locally
curl
requesthttr::get
@statsRhian