Converting shiny input as variable in Meta Regression

Hi Friends
when I pass variable through shinyinput to the regression, the output does not display the column name.
appearing as
factor(m1dat12[, input$mModeratorVar])random
factor(m1dat12[, input$mModeratorVar])systematic

would like to see in this format (group_name is the column name selected)
factor(group_name)random
factor(group_name)systematic

reference: Meta-Regression Models With or Without an Intercept [The metafor Package]
In this blog, moderator variable is hardcoded as given below
res <-(yi, vi, mods = ~ ablat, data=dat)
here ablat is appearing in the output. but when I pass shinyinput the name is not appearing in the output. this is where, I am trying to sort help from the community.
could someone help me out
thanks

You can use renderUI() and pass the text in to it. Sort of like this: Shiny - Display reactive output

Really sorry, I am missing something, I am not able to get the desired results. could you please add a minimum example code
Thank you very much for your support
Ganapathy

Can you provide a reproducible example of your application? I assume that input$mModeratorVar is ablat in your example and that you want to have that in the model, but also as text.

Sorry for the delay, your assumption is correct, I want to use the input and show the input by name
Thank you

Hi Good Morning
any input on this

thanks
Ganapathy

Can you provide a reproducible example of your application?

Hi Good Morning
here is the code having reference to the dataset as well. I have used "dat.bcg" dataset builtin with library(metafor). Thank you for your support

#############################################
library(shiny)

ui <- fluidPage(
fluidRow(
align = "center",
column(style = "border: 4px double red;height: 525px;overflow-y: auto;",
width = 3,
aligh = "center",
br(),
selectInput(inputId = 'mModeratorVar',label = 'Select Moderator',choices = c('ablat','alloc'),selected='alloc',multiple = FALSE)
),

column(style = "border: 4px double red;height: 525px;overflow-y: auto;",
       width = 9,
       HTML(paste('<h4><b>',"Meta Regression",'<h5></b>')),
       verbatimTextOutput('mMetaRegressionTxt2')
)

) #fluid row

)

server <- function(input, output, session) {
library(metafor)
data("dat.bcg")
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

output$mMetaRegressionTxt2 <- renderPrint({
rma(yi, vi, mods = ~ factor(dat[,input$mModeratorVar]), data=dat)
})

}
shinyApp(ui, server)
#############################################################

for me output is showing like this

output is required like this: I need name of the variable to be shown instead of Input$mModeratorVar

1 Like

This topic was automatically closed 7 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.