在R SHILY中选择未定义的列(&Q;)未定义、SHILY、amp

2023-09-03 14:02:02 作者:童色安年*

我有一个日期框文件1,其中列V2包含时间,V3-V13是参数。

我想绘制时间与R中的参数的关系图。我可以获得摘要和表值,但在绘图中显示"选中未定义的列"。任何指针都有帮助。

华硕x450j如何用u盘启动项

汇总值和表值如期到来

下面是我的UI.R和服务器。R

 - SERVER.R
server <- function(input, output) {
file1 = read.csv(file = "RawData_METHODIST_WOODLANDS_MethodistWoodlands_ YK 
CH1_1_4_2017_to_27_04_2017_new.csv", header = FALSE)
as.data.frame(file1)
# Return the requested dataset ----
file <- reactive({
switch(input$sel, 
       "WAR-CODE ( States )" = file1$V3,
       "VSD-CONVHS-T ( degF )" = file1$V4,
       "MANUAL PRV % OPEN ( % )" = file1$V5,
       "WIND SPEED ( mph )" = file1$V6,
       "REFPOS-SP ( % )" = file1$V7,
       "MOT-FLA ( % )" = file1$V8,
       "LL-SV-STS ( offon )"  = file1$V9,
       "TEMPERATURE ( degF )" = file1$V10,
       "EVAP-P ( psi )" = file1$V11,
       "VSD OP-Hz ( hz )" = file1$V12,
       "MANUAL EVAP RETURN PRESSURE ( psi )" = file1$V13)
  })
# Generate a summary of the dataset ----
output$summary <- renderPrint({
file1 <- file()
summary(file1)
})
output$plot1 <- renderPlot({
print(input$sel)
file1 <- file()
file1 <- as.data.frame(file1)
Time1 = strptime(file1$V2,format = "%Y-%m-%d %H:%M:%S")
plot(Time1,file1[,input$sel])
})
# Show the first "n" observations ----
output$view <- renderTable({
head(file(), n = input$obs)
head(file(), n = input$obs)
})
}

- UI.R

# Define UI for dataset viewer app ----
ui <- fluidPage(

# App title ----
titlePanel("PLOTS FOR JCI"),

# Sidebar layout with a input and output definitions ----
sidebarLayout(

# Sidebar panel for inputs ----
sidebarPanel(

  # Input: Selector for choosing dataset ----
  selectInput(inputId = "sel",
              label = "Choose a Parameter:",
              choices = c("WAR-CODE ( States )" , "VSD-CONVHS-T ( degF )", 
   "MANUAL PRV % OPEN ( % )","WIND SPEED ( mph )","REFPOS-SP ( % )","MOT-FLA 
  ( % )","LL-SV-STS ( offon )","TEMPERATURE ( degF )", "EVAP-P ( psi )","VSD 
  OP-Hz ( hz )","MANUAL EVAP RETURN PRESSURE ( psi )")),
  # Input: Numeric entry for number of obs to view ----
  numericInput(inputId = "obs",
               label = "Number of observations to view:",
               value = 10)
  ),
  # Main panel for displaying outputs ----
  mainPanel(
             tabsetPanel(type = "tabs",
              tabPanel("Plot", plotOutput("plot1")),
              tabPanel("Summary", verbatimTextOutput("summary")),
              tabPanel("Table", tableOutput("view"))
       )
     )
    )
   )
shinyApp(ui,server)

推荐答案

终于成功了。我使用了如下所示的renderploy()。

output$plot1 <- renderPlot
({  
plot(Time1,file())  
})