首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行用于微元分析的闪亮应用程序脚本有困难

运行用于微元分析的闪亮应用程序脚本有困难
EN

Stack Overflow用户
提问于 2021-08-18 01:52:16
回答 1查看 74关注 0票数 0

我正在尝试从一个关于元分析的研讨会中加载一个脚本,它应该为您提供一个运行元分析的应用程序/工具。脚本如下所示:

代码语言:javascript
复制
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)

然而,当我运行它时,它简要地显示了我想要的,然后给出了这个错误:

监听http://127.0.0.1:4427警告: setwd中的错误:无法更改工作目录50: setwd 49:服务器#4 setwd(this.dir):无法更改工作目录

我不知道这意味着什么。我假设它指的是代码的这一特定部分,但是,我不确定是否应该对此进行修改:

代码语言:javascript
复制
  this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
  setwd(this.dir)
  source("minimetacor.R")

有人能提供一些洞察力吗?我不想编辑错误的东西,它变得不可行。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-18 02:59:39

看起来我只需要下载另一个文件,在我提到的目录代码中显示的"minimetacor“文件:

代码语言:javascript
复制
  this.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
  setwd(this.dir)
  source("minimetacor.R")

一旦我下载了微型元文件并下载了我正在使用的脚本,我就把它们放在同一个文件夹中,然后再次运行脚本。它马上就起作用了。

感谢MrFlick的帮助!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68825695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档