在R SHILY中选择未定义的列(&Q;) [英] Getting "undefined columns selected" in R shiny
本文介绍了在R SHILY中选择未定义的列(&Q;)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个日期框文件1,其中列V2包含时间,V3-V13是参数。
我想绘制时间与R中的参数的关系图。我可以获得摘要和表值,但在绘图中显示"选中未定义的列"。任何指针都有帮助。
汇总值和表值如期到来
下面是我的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())
})
这篇关于在R SHILY中选择未定义的列(&Q;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文