I was plotting a bar plot using ggplot and I created this function as a web api using plumber package in R.
library(plumber)
library(ggplot2)
#' @get /histogram_test
#' @png
histogram_test <- function(){
mtcars=mtcars
b=ggplot(mtcars,aes(mtcars$cyl))
b+geom_bar()
}
Then I run:
r <- plumb("plum_api.R")
r$run(port=8000)
But this does not return the plot on the browser.
So it works if in the last line we just use the print command as: print(b+geom_bar()).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With