遇到问题 运行 用于迷你元分析的闪亮应用脚本
Having trouble running Shiny app script for mini meta analysis
我正在尝试从关于荟萃分析的研讨会上加载一个脚本,据说它可以为您提供 app/tool 到 运行 的荟萃分析。脚本如下所示:
if(!require(shiny)){install.packages('shiny')}
if(!require(shinythemes)){install.packages('shinythemes')}
if(!require(rstudioapi)){install.packages('rstudioapi')}
library(shiny)
library(shinythemes)
ui <- fluidPage(theme=shinytheme("flatly"),
titlePanel("Mini meta-analysis of your own studies (correlations)"),
sidebarLayout(
sidebarPanel(
h6("To create the mini meta-analysis, you need to upload a CSV file with the following columns:"),
h6("Study: Name of the study/experiment [String]"),
h6("N : Sample size"),
h6("R : Correlation between X and Y"),
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"))
),
mainPanel(h3("Loaded file:"), br(),
tableOutput("fileload"), br(),
h3("Meta analysis Results:"), br(),
h5(verbatimTextOutput("metaresult")), br(),
plotOutput("forestplot"),br(),
plotOutput("funnelplot"),br(),
h3("Test for asymmetry & trim-fill procedure"), br(),
h5(verbatimTextOutput("metaresult3")), br(),
h5(verbatimTextOutput("metaresult2")), br(),
plotOutput("funnelplottrim"))
)
)
server <- function(input, output) {
this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(this.dir)
source("minimetacor.R")
InFile <- reactive({
validate(
need(input$file1, "Choose a file to see meta-analysis output results!")
)
inFile <- input$file1
if (is.null(inFile))
return(NULL)
idataset <- read.table(inFile$datapath, header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)
})
MetaFile <- reactive({
idata <-InFile()
odataset<-CorMeta(idata$R, idata$N,idata$Study)
})
output$forestplot <- renderPlot({
PrintPlotMetaR(MetaFile())
})
output$metaresult <- renderPrint({
summary(MetaFile())
})
output$metaresult2 <- renderPrint({
taf <- trimfill(MetaFile())
taf
})
output$metaresult3 <- renderPrint({
regtest(MetaFile())
})
output$fileload <- renderTable({
InFile()
})
output$funnelplot <- renderPlot({
PrintFunnelMetaR(MetaFile())
})
output$funnelplottrim <- renderPlot({
taf <- trimfill(MetaFile())
taf
PrintFunnelMetaR(taf)
})
}
shinyApp(ui = ui, server = server)
但是当我 运行 它时,它简要地显示了我想要的,然后给了我这个错误:
Listening on http://127.0.0.1:4427 Warning: Error in setwd: cannot
change working directory 50: setwd 49: server [#4] Error in
setwd(this.dir) : cannot change working directory
我不确定这是什么意思。我假设它指的是代码的这个特定部分,但是,我不确定我是否应该 fiddle 这样:
this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(this.dir)
source("minimetacor.R")
任何人都可以提供一些见解吗?我不想编辑错误的东西,它变得不可行。
看来我只需要下载另一个文件,我提到的这个目录代码中显示的“minimetacor”文件:
this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(this.dir)
source("minimetacor.R")
一旦我下载了 minimetacor 文件并下载了我正在使用的脚本,我将它们放在同一个文件夹中,然后再次 运行 脚本。马上就见效了。
感谢 MrFlick 的帮助!
我正在尝试从关于荟萃分析的研讨会上加载一个脚本,据说它可以为您提供 app/tool 到 运行 的荟萃分析。脚本如下所示:
if(!require(shiny)){install.packages('shiny')}
if(!require(shinythemes)){install.packages('shinythemes')}
if(!require(rstudioapi)){install.packages('rstudioapi')}
library(shiny)
library(shinythemes)
ui <- fluidPage(theme=shinytheme("flatly"),
titlePanel("Mini meta-analysis of your own studies (correlations)"),
sidebarLayout(
sidebarPanel(
h6("To create the mini meta-analysis, you need to upload a CSV file with the following columns:"),
h6("Study: Name of the study/experiment [String]"),
h6("N : Sample size"),
h6("R : Correlation between X and Y"),
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"))
),
mainPanel(h3("Loaded file:"), br(),
tableOutput("fileload"), br(),
h3("Meta analysis Results:"), br(),
h5(verbatimTextOutput("metaresult")), br(),
plotOutput("forestplot"),br(),
plotOutput("funnelplot"),br(),
h3("Test for asymmetry & trim-fill procedure"), br(),
h5(verbatimTextOutput("metaresult3")), br(),
h5(verbatimTextOutput("metaresult2")), br(),
plotOutput("funnelplottrim"))
)
)
server <- function(input, output) {
this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(this.dir)
source("minimetacor.R")
InFile <- reactive({
validate(
need(input$file1, "Choose a file to see meta-analysis output results!")
)
inFile <- input$file1
if (is.null(inFile))
return(NULL)
idataset <- read.table(inFile$datapath, header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)
})
MetaFile <- reactive({
idata <-InFile()
odataset<-CorMeta(idata$R, idata$N,idata$Study)
})
output$forestplot <- renderPlot({
PrintPlotMetaR(MetaFile())
})
output$metaresult <- renderPrint({
summary(MetaFile())
})
output$metaresult2 <- renderPrint({
taf <- trimfill(MetaFile())
taf
})
output$metaresult3 <- renderPrint({
regtest(MetaFile())
})
output$fileload <- renderTable({
InFile()
})
output$funnelplot <- renderPlot({
PrintFunnelMetaR(MetaFile())
})
output$funnelplottrim <- renderPlot({
taf <- trimfill(MetaFile())
taf
PrintFunnelMetaR(taf)
})
}
shinyApp(ui = ui, server = server)
但是当我 运行 它时,它简要地显示了我想要的,然后给了我这个错误:
Listening on http://127.0.0.1:4427 Warning: Error in setwd: cannot change working directory 50: setwd 49: server [#4] Error in setwd(this.dir) : cannot change working directory
我不确定这是什么意思。我假设它指的是代码的这个特定部分,但是,我不确定我是否应该 fiddle 这样:
this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(this.dir)
source("minimetacor.R")
任何人都可以提供一些见解吗?我不想编辑错误的东西,它变得不可行。
看来我只需要下载另一个文件,我提到的这个目录代码中显示的“minimetacor”文件:
this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(this.dir)
source("minimetacor.R")
一旦我下载了 minimetacor 文件并下载了我正在使用的脚本,我将它们放在同一个文件夹中,然后再次 运行 脚本。马上就见效了。
感谢 MrFlick 的帮助!