Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中编辑模式弹出窗口的内容_R_Shiny - Fatal编程技术网

在R中编辑模式弹出窗口的内容

在R中编辑模式弹出窗口的内容,r,shiny,R,Shiny,我想在R中编辑模式弹出窗口的内容。下面是我的代码,我可以用它打印模式弹出窗口中的值,但我不能编辑它 Server.R modelnetlist <- function(failed = FALSE){ netlistdata <- readLines('run.scs') splitText1 <- stringi::stri_split(str = netlistdata, regex = '\\n') # wrap a paragraph

我想在R中编辑模式弹出窗口的内容。下面是我的代码,我可以用它打印模式弹出窗口中的值,但我不能编辑它

Server.R

modelnetlist <- function(failed = FALSE){
    netlistdata <- readLines('run.scs')
    splitText1 <- stringi::stri_split(str = netlistdata, regex = '\\n')
    
    # wrap a paragraph tag around each element in the list
    replacedText1 <- lapply(splitText1, p)
    modalDialog(
      title = "Netlist File",
      replacedText1,
      easyClose = FALSE,
      footer = tagList(
        modalButton("Close"),
        actionButton("save", "Save")
      )
    )

  }
  
  observeEvent(input$gennet, {
    
    showModal(modelnetlist())
  })

ui.R

options(shiny.maxRequestSize=100*1024^2)
ui <- dashboardPage(skin = "yellow",
                    dashboardHeader(title = "Modelling Automation"), 
                    dashboardSidebar(
                      sidebarMenu(
                        # Setting id makes input$tabs give the tabName of currently-selected tab
                        id = "tabs",
                        
                        menuItem("Data Processing", tabName = "DP", icon = icon("database"), startExpanded = TRUE,
                                 menuSubItem("Merge", tabName= "Merge"),
                                 menuSubItem("Data", tabName = "Data"),
                                 menuSubItem("Plot", tabName = "Plot", selected = TRUE),
                                 menuSubItem("Parameters", tabName = "Parameters")),
                        menuItem("Parameter Extraction", icon = icon("book-open"), tabName = "PE"),
                                  menuSubItem("Data Conversion", tabName = "DC"),
                                  menuSubItem("IPL Upload", tabName = "IPL"),
                                  menuSubItem("Netlist Spectre", tabName = "netlist"),
                                  menuSubItem("Spectre logs", tabName = "mylog"),
                                  menuSubItem("Parameter Fitting", tabName = "PF"),
                        
                        
                        menuItem("Model QA", tabName = "QA", icon = icon("angellist"))
                      ),
                      
                      textOutput("res")
                    ),
                    
                    dashboardBody(
                      tabItems(
                        tabItem("DP", "Dashboard tab content"),
                        #tabItem("PE", "Widgets tab content"),
                        tabItem("Merge", fileInput("mergefiles", "choose the files", accept = c(".txt"), multiple = TRUE), downloadButton("Download", label = "Merged File")),
                        tabItem("Data",
                                
                                mainPanel(div(style='overflow-x:scroll',tableOutput("txt"),tableOutput("filetable"),tableOutput("filetable1")))
                        ),
                        
                        tabItem("Plot",sidebarLayout(sidebarPanel(width=3,
                                                                  fileInput("datasets", "choose the files", accept = c(".txt",".esd"), multiple = TRUE),
                                                                  uiOutput("plotdata"),uiOutput("devicetype"), uiOutput("chip"),
                                                                  uiOutput("macro"),
                                                                  uiOutput("device"),fluidRow(column(5,uiOutput("minIT2")),column(5,uiOutput("maxIT2"))),
                                                                  fluidRow(column(5,uiOutput("temperature")), column(5,uiOutput("DCleakage"))),
                                                                  fluidRow(column(5,uiOutput("varx")),column(5,uiOutput("vary")))
                        ),
                        mainPanel(width=9,
                                  plotlyOutput("PLOT")))),
                        
                        tabItem("Parameters",tags$style(type="text/css",
                                  ".shiny-output-error { visibility: hidden; }",
                                 ".shiny-output-error:before { visibility: hidden; }"),
                                div(style="display:inline-block;width:32%;text-align: center;",actionButton("action", label = "Normalize")),
                                tabsetPanel(type="tabs",
                                            tabPanel("CV Table",div(style='overflow-x:scroll',dataTableOutput('DiodeCVTable')),fluidRow(column(5, actionButton("perimeterCV", label="Change Perimeter")),column(5, actionButton("changeCV", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicCV")),column(5,uiOutput("goldenchipCV"))),plotlyOutput("cvplot")),
                                            tabPanel("DC Table",div(style='overflow-x:scroll',dataTableOutput('DiodeDCTable')),fluidRow(column(5, actionButton("perimeterDC", label="Change Perimeter")),column(5, actionButton("changeDC", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicDC")),column(5,uiOutput("goldenchipDC"))),plotlyOutput("dcplot")),
                                            tabPanel("TLP Table",div(style='overflow-x:scroll',dataTableOutput('TLPTable')), fluidRow(column(5, actionButton("perimeterTLP", label="Change Perimeter")),column(5, actionButton("changeTLP", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicTLP")),column(5,uiOutput("goldenchipTLP"))),plotlyOutput("tlpplot")),
                                            tabPanel("VFTLP Table",div(style='overflow-x:scroll',dataTableOutput('VFTLPTable')), fluidRow(column(5, actionButton("perimeterVFTLP", label="Change Perimeter")),column(5, actionButton("changeVFTLP", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicVFTLP")),column(5,uiOutput("goldenchipVFTLP"))), plotlyOutput("vftlpplot")))),
                        
                        tabItem("PE","Parameter Extraction Content"),
                        tabItem("DC",uiOutput("onedevice"),uiOutput('tabs'), 
                               
                                   conditionalPanel(condition="input.layer=='CV'", plotlyOutput("plotcv1"),br(), tableOutput("device1cv")),
                                #conditionalPanel(condition="input.layer=='CV 2'", plotlyOutput("plotcv2"),br(), tableOutput("device2cv")),
                               # conditionalPanel(condition="input.layer=='CV 3'", plotlyOutput("plotcv3"),br(), tableOutput("device2cv")),
                                conditionalPanel(condition="input.layer=='DC @ 25'", plotlyOutput("plotdc125"),br(), tableOutput("device1dc25")),
                                conditionalPanel(condition="input.layer=='DC @ -40'", plotlyOutput("plotdc140"),br(), tableOutput("device1dc40")),
                                conditionalPanel(condition="input.layer=='DC @ 125'", plotlyOutput("plotdc1125"),br(), tableOutput("device1dc125")),
                                conditionalPanel(condition="input.layer=='DC @ 150'", plotlyOutput("plotdc1150"),br(), tableOutput("device1dc150")),
                                conditionalPanel(condition="input.layer=='TLP'",fluidRow(column(3,uiOutput("stepcountTLP")), column(3, uiOutput("maxvoltageTLP")), column(3, uiOutput("VholdTLP")), downloadButton("DownloadTLP",label = "Download converted data")), plotlyOutput("plottlp1"),br(), tableOutput("device1tlp")),
                               #conditionalPanel(condition="input.layer=='TLP 2'", plotlyOutput("plottlp2"),br(), tableOutput("device2tlp")),
                               
                                 conditionalPanel(condition="input.layer=='VFTLP'",fluidRow(column(3,uiOutput("stepcountVFTLP")), column(3, uiOutput("maxvoltageVFTLP")), column(3, uiOutput("VholdVFTLP"))), plotlyOutput("plotvftlp1"),br(), tableOutput("device1vftlp"))
                                
                                ),
                        tabItem("PF",  uiOutput('modelingtabs'),
                                conditionalPanel(condition="input.modtab=='CV'",tableOutput("modelingdevice1CV")),
                                conditionalPanel(condition= "input.modtab=='DC @ 25'", tableOutput("modelingdevice1DC25")),
                                conditionalPanel(condition= "input.modtab=='DC @ 40'", tableOutput("modelingdevice1DC40")),
                                conditionalPanel(condition= "input.modtab=='DC @ 125'", tableOutput("modelingdevice1DC125")),
                                conditionalPanel(condition= "input.modtab=='DC @ 150'", tableOutput("modelingdevice1DC150")),# plotlyOutput("plotcv1"),br(), tableOutput("device1cv")),
                                conditionalPanel(condition="input.modtab=='TLP'",tableOutput("modelingdevice1TLP")),# plotlyOutput("plottlp1"),br(), tableOutput("device1tlp")),
                                conditionalPanel(condition="input.modtab=='VFTLP'",tableOutput("modelingdevice1VFTLP"))#, plotlyOutput("plotvftlp1"),br(), tableOutput("device1vftlp"))
                        ),
                        tabItem("IPL", 
                                fluidRow(box(title = "Model Inputs", width = 8,
                                         fileInput("iplfile", "choose the IPL file", accept = c(".xlsx"), multiple = TRUE),
                                         column(3, uiOutput("modeltype")),
                                         column(3,uiOutput("modeldevtype")),
                                         column(3,uiOutput("modelpath")), 
                                         column(3, uiOutput("wrapperfile")),
                                         column(3,uiOutput("zapcon")), 
                                         column(3,uiOutput("polarity")),
                                         column(3,uiOutput("sectiontype")),
                                         column(3,uiOutput("designfile")), 
                                         column(3, uiOutput("esd_event")),
                                         column(3, uiOutput("esd_exit")),
                                         column(3, uiOutput("modelnodeorder")),
                                         column(3, uiOutput("terminalbias")),
                                         column(3,uiOutput("design")),
                                         column(3,uiOutput("modtemp")),
                                         column(3,uiOutput("ylogaxis")))), 
                                         box(title = "Model Parameters in IPL", width = 20, tableOutput("IPLTable"),
                                             uiOutput("newvalue1"),
                                             uiOutput("newvalue2"),
                                             uiOutput("newvalue3"),
                                             uiOutput("newvalue4"))
                                ,fluidRow(box(width = 6, height = 60,actionButton("SpecPlot", label="Spectre Plot", width = 100),
                                              # bsModal("netl", strong("Netlist File", style="color:#0000ff; font-size:120%"), 
                                              #         "gennet", size = "large", uiOutput("modelnetlist")),
                                          actionButton("HspiPlot", label="Hspice Plot", width = 100),
                                          actionButton("gennet", label="Generate netlist"),
                                          actionButton("ChangeValues", label="Change Values"),
                                          actionButton("save", label = "Save"),
                                          actionButton("Mergesim", label="Merge Simulation Plots"))),
                                          uiOutput("newvalues"),  
                                          #conditionalPanel(condition = "input$specplot", withSpinner(plotlyOutput("plotspe"), type = 1, hide.ui = FALSE)),
                                          tags$head(
                                          tags$style(
                                          HTML(".shiny-notification {
                                          height: 100px;
                                          width: 500px;
                                          position:fixed;
                                          top: calc(50% - 50px);;
                                          left: calc(50% - 400px);;
                                          }
                                          "
                                          )
                                            )
                                              ),
                                          #box(title = "Simulation", status = "primary", plotlyOutput("plotspe", height = 250)),
                                          fluidRow(column(width=6,
                                                          fluidRow(plotlyOutput("plotspe",width = "100%", height = "400px", inline = FALSE))),
                                                          
                                                   column(width=6,
                                                          fluidRow(plotlyOutput("plothspi",width = "100%", height = "400px", inline = FALSE)))),
                                          fluidRow(column(width=6,fluidRow(plotlyOutput("plotspechspi",width = "100%", height = "400px", inline = FALSE)))),
                                          # splitLayout(style = "height:400px;", cellWidths = c("800", "800"),
                                          #             plotlyOutput("plotspe"), plotlyOutput("plothspi"))
                                          # ,
                                          plotlyOutput("plottlpalongspectre")
                                          ),
                        tabItem("netlist", fluidPage(uiOutput("netlistfile"))),
                        tabItem("mylog", fluidPage(uiOutput("logfile"))),
                        
                        tabItem("QA", " QA tab content")# actionButton("ChangeValues", label="Change Values"
                      )
                    )
)

**run.scs file:** (File that I'm calling in modelnetlist function to read and display it in the modal)

Simmulator lang=spectre
global 0
paropt options redefinedparams= ignore 
parameters vnw=0 vnd=0 
parameters area_1=5.5e-12 
Server.R

modelnetlist在
modalDialog
函数中,您几乎可以使用任何UI元素(请参见
参数)


注意:保存文件的路径必须是可写的。

您能让您的问题重现吗?要我添加用户界面代码吗?已经附加了我的服务器逻辑和我正在读取和显示的文件,至少您必须输入
textAreaInput
,才能“输入”修改。您所说的第一次尝试完全是静态的(显示)。您尝试过这样做吗?是的,将其作为一个正在运行的应用程序将很有帮助,这样我们就可以测试我们的答案,并确保它确实按照预期工作。如果你是
ui
代码不太长,你可以在这里添加它。@RonakShah我也添加了我的ui.R文件。抱歉,它太大了。但我认为现在你会被复制。在IPL upload选项卡中查找按钮Generate netlist。获取此错误,“writeImpl中的错误:要写入的文本必须是长度为一个字符的向量”,它与以下代码“textAreaInput”(“脚本”,“netlist”,value=replacedText1,width=“750px”,height=“1000px”)一起工作。但是文本显示时会附加一个“”模拟器lang=spectre

”。如何删除?读线返回时需要单个字符串,而不是字符串向量。所以需要使用新行连接它们(更新了我的答案)。无需更换/添加p。直接从文件(粘贴过程中插入换行符除外)可以帮助您将textinput内容保存为run.scs文件吗?我尝试使用input$theScript,但无法保存它。我修改了代码,将内容保存到文件中
modelnetlist <- function(failed = FALSE){
  netlistdata <- paste(readLines('run.scs'),collapse="\n")
  modalDialog(
    title = "Netlist File",
    textAreaInput("theScript", value=netlistdata),
    easyClose = FALSE,
    footer = tagList(
      modalButton("Close"),
      actionButton("save", "Save")
    )
  )
}
observeEvent(input$save, {
  # do whatever you want with input$theScript
  if(isTruthy(input$theScript))
    writeLines(input$theScript, "run.scs")
})