Search code examples
rjsonapiplumberrjson

Run a Multiple function with same argument but it skip first function and print second function using plumber in R


i have main function which include two sub function with same argument in both function fun1 and fun2 and function prints fun2 but unable to print fun1 using plumber in swagger console don't know why?

and

here is my code

library(plumber)
library(tibble)

#* @get /Query 

detailData <- function(query = ""){
  print(query)
  library(gwasrapidd)
  fun1(query)
  fun2(query)

output of fun2 function and unable to get fun1 function

[
  {
    "study_id": "GCST002305",
    "pubmed_id": 24325915,
    "title": "Genome-wide association study identifies 25 known breast cancer susceptibility loci as risk factors for triple-negative breast cancer."
  },
  {
    "study_id": "GCST010100",
    "pubmed_id": 32424353,
    "title": "Genome-wide association study identifies 32 novel breast cancer susceptibility loci from overall and subtype-specific analyses."
  }
]

I want both function in single object like fun1 is studies and fun2 is publication

[
    studies:{
        "study_id": "GCST002305",
        "gxe": false
    },
    {
        "study_id": "GCST010100",
        "gxe": false,
        "snp_count": 9700000
    },
    
    publication{
        "study_id": "GCST002305",
        "pubmed_id": 24325915,
        "title": "Genome-wide association study identifies 25 known breast cancer susceptibility loci as risk factors for triple-negative breast cancer."
    },
    {
        "study_id": "GCST010100",
        "pubmed_id": 32424353,
        "title": "Genome-wide association study identifies 32 novel breast cancer susceptibility loci from overall and subtype-specific analyses."
    }
]

Solution

  • You do not need to print inside a plumber function.

    library(plumber)
    library(tibble)
    library(gwasrapidd)
    
    #* @get /query 
    function(query = ""){
        list(query, fun1(query), fun2(query))
    }