0

I am Developing an API for that I am using Plumber. I have created two function with its each endpoint. I want to use function 1 as argument in function 2 OR inheritance for example function 1 should be my parent class and function 2 will be my child class.

I want to reuse the code of function 1 for executing function 2 output.

I don't know how to do!

Please Help

Thank You in Advance

Function 1

library(plumber)
library(gwasrapidd)

#* @get /Query    

simplequery <- function(query=""){

    studies <- get_studies(study_id = query) 

  }

Function 2

#* @get /GetData
    
    Getdata <- function(of=""){
          
          if (of == "Studies"){
            
            study_table <- studies@studies
            
            .....
          }
        }

1 Answers1

0

I have used with function to inherit my function.

abc <- function{
    with(parent.frame(),{
       function_statement
    })
}

efg<- function{
    d <- abc()
    function_statement
}

what it does is that efg function calls the abc function