Include R code in Plumber API Deployed at Digital Ocean

I have figured out how to build an API end point using plumberDeploy at Digital Ocean. This example works as expected

#* Return the sum of two numbers
#* @param a The first number to add
#* @param b The second number to add
#* @get /sum
function(a, b) {
  as.numeric(a) + as.numeric(b) 
}

This example does not work as expected

#* Return the sum of two numbers
#* @param a The first number to add
#* @param b The second number to add
#* @get /sum
function(a, b) {
  myAdd(a,b)
}

myAdd <- function(x,y){
	x + y
}

How can I have custom functions that work inside the API endpoint? This is a toy example, my real world scenario has many other functions that do not live in an R package and I do not want to build a package.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.