plumber

Read local csv in plumber API

狂风中的少年 提交于 2021-02-16 21:06:36
问题 I want to read and process a csv file by R using plumber. So far I found an ongoing discussion regarding file uploads in plumber on GitHub (though regarding binary files) and this SO answer (transforming JSON file), both supposing the use of postBody . I therefore started with this endpoint: library(plumber) #* parse csv file #* @param req the request object #* @post /file function(req) { result <- req$postBody return(result) }) When testing the endpoint using httr , I can read the file as

Read local csv in plumber API

时光毁灭记忆、已成空白 提交于 2021-02-16 21:02:56
问题 I want to read and process a csv file by R using plumber. So far I found an ongoing discussion regarding file uploads in plumber on GitHub (though regarding binary files) and this SO answer (transforming JSON file), both supposing the use of postBody . I therefore started with this endpoint: library(plumber) #* parse csv file #* @param req the request object #* @post /file function(req) { result <- req$postBody return(result) }) When testing the endpoint using httr , I can read the file as

Is there a way to add optional parameter in API using R Plumber?

北城以北 提交于 2021-01-28 08:47:17
问题 I have this routing that I'm trying to make it work: #* @get /outcomes-aggregate/<categoryId:int>/<classId>/<perspectiveID>/<sn> #* @serializer unboxedJSON function(res, req, categoryId, classId,sn=NULL){ ## initialization query <- NULL data_to_send <- list() ... } This api is supposed to take the request with optional sn value. However, this is not working. The sn value may or may not exist and the query is ran based on this value. But when I run it, I keep getting this error: call: http:/

Using R's Plumber - create GET endpoint to host CSV formatted data rather than JSON

蓝咒 提交于 2021-01-23 05:12:35
问题 I think this is a good quick demo of R's plumber library in general, but mainly I'm struggling to serve data in a csv format I am working with R's plumber package to host an API endpoint for some sports data of mine. Currently I have some data that grabs win totals for MLB baseball teams that I'm trying to serve. Using plumber, I have the following 2 scripts set up: setupAPI.R : sets up my API with two GET endpoints: library(plumber) library(jsonlite) # load in some test sports data to host

Using R's Plumber - create GET endpoint to host CSV formatted data rather than JSON

不打扰是莪最后的温柔 提交于 2021-01-23 04:56:51
问题 I think this is a good quick demo of R's plumber library in general, but mainly I'm struggling to serve data in a csv format I am working with R's plumber package to host an API endpoint for some sports data of mine. Currently I have some data that grabs win totals for MLB baseball teams that I'm trying to serve. Using plumber, I have the following 2 scripts set up: setupAPI.R : sets up my API with two GET endpoints: library(plumber) library(jsonlite) # load in some test sports data to host

R plumber on Linux Server

人盡茶涼 提交于 2019-12-23 01:18:15
问题 I've made a .R file with a plumber code. The file works fine on my local pc, it works also fine on my linux server. My only problem now is, that it's only local. I need to be able to get the API over the server adress. The server also runs a cronR process which makes all the math and a shiny-app to display some graphs. All the math is stored into an cvs file and plumber should now get the last index and display this so I can use it from everywhere. Are there any solutions? Code: library

Deploying plumber API via rsconnect (Handler not found)

梦想与她 提交于 2019-12-13 03:49:41
问题 I have a directory with a example API function ( testAPI.R ): #* @get /mean normalMean <- function(samples=10){ library(plumber) data <- rnorm(samples) mean(data) } The rsconnect::deployAPI() function wants to point to a directory with a file named plumber.R that returns a plumb object. So I have the file plumber.R in the directory as: library(plumber) plumber::plumb("testAPI.R") And then calling rsconnect::deployAPI() on the directory... It deploys with no errors but seems to have not found

How to send json response using plumber R

南笙酒味 提交于 2019-12-12 19:16:32
问题 I need to send response from R using plumber package in below format { "status": "SUCCESS", "code": "200", "output": { "studentid": "1001", "name": "Kevin" } } But I am getting below format [ "{\n \"status\": \"SUCCESS\",\n \"code\": \"200\",\n \"output\": {\n \"studentid\": \"1001\",\n \"name\": \"Kevin\"\n }\n}" ] Please help me format this json properly My Code #* @post /sum addTwo <- function(){ library(jsonlite) x <- list(status = "SUCCESS", code = "200",output = list(studentid = "1001",

R plumber JSON serializer auto_unbox

北慕城南 提交于 2019-12-12 16:17:36
问题 Following the example on the page http://plumber.trestletech.com/ I wrote myfile.R as #* @post /test test <- function(){ list(speech='aa',source='bb',displayText='cc') } And I ran the plumber code on it to convert int into an API library(plumber) r <- plumb("~/Work/myfile.R") r$run(port=8000) And Now when I perform an POST request on it using I get curl -XPOST 'localhost:8000/test -> {"speech":["aa"],"source":["bb"],"displayText":["cc"]} But I want the square brackets to be removed. In simple

google app engine flexible with docker 'site cannot be reached'

北城以北 提交于 2019-12-11 17:14:52
问题 I want to server R model using App Engine. I am following this example R with app engine, but stuck. I tried several methods but still have issues. Any guidance on this issue? Please refer to my code app.yaml runtime: custom env: flex Dockerfile FROM gcr.io/gcer-public/plumber-appengine LABEL maintainer="mark" RUN R -e "install.packages(c('plumber'), repos='http://cran.rstudio.com/')" WORKDIR /payload/ COPY [".", "./"] EXPOSE 8080 ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4])