我正在使用基本的闪亮代码,当我尝试显示表输出时出现错误,但是当我将行更改为renderprint时会打印相同的数据帧,我可以使用下载处理程序下载文件,其中显示了那里的记录。 “警告:<-:要替换的项目数不是替换长度的倍数” 我的数据集和代码如下。
structure(list(Point1 = c(9999, 9999, 433.333, 9999, 1433.333,
33.333, 4283.333, 9999, 33.333, 9999, 9999, 9999, 9999, 0.033,
1323.333, 883.333, 9999, 9999, 9999, 9999, 433.333, 1433.333,
0.633, 9999, 9999, 9999, 33.333, 9999, 133.333, 433.333, 433.333,
0.003, 4023.333, 33.333, 423.333, 1323.333, 423.333, 1323.333,
4323.333, 2073.333, 1323.333, 1323.333, 1323.333, 1323.333, 1323.333,
33.333, 123.333, 3363.333, 123.333, 0.333, 423.333), Point2 = c(4433.333,
4433.333, 133.333, 4133.333, 433.333, 3.333, 1283.333, 4433.333,
3.333, 4433.333, 4433.333, 4433.333, 4433.333, 0.003, 423.333,
433.333, 4433.333, 4433.333, 4433.333, 4433.333, 133.333, 433.333,
0.333, 4358.333, 4433.333, 4433.333, 3.333, 4433.333, 33.333,
133.333, 133.333, NA, 1323.333, 3.333, 123.333, 423.333, 123.333,
423.333, 1323.333, 1323.333, 423.333, 423.333, 423.333, 423.333,
423.333, 3.333, 33.333, 1323.333, 33.333, 0.033, 123.333), OUTP1 = c(NA,
NA, 1L, NA, 1L, 1L, 1L, NA, 1L, NA, NA, NA, NA, 1L, 1L, 1L, NA,
NA, NA, NA, 1L, 1L, 1L, NA, NA, NA, 1L, NA, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), Types = c(NA, NA, 3L, NA, 3L, 3L, 3L, NA, 3L, NA, NA,
NA, NA, 3L, 3L, 3L, NA, NA, NA, NA, 3L, 3L, 3L, NA, NA, NA, 3L,
NA, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L)), .Names = c("Point1", "Point2",
"OUTP1", "Types"), class = "data.frame", row.names = c(NA, -51L
))
library(survival)
library(shiny)
ui <- bootstrapPage(
titlePanel("Title comes here"),
tags$hr(),
sidebarPanel(
fileInput("file1", "Choose CSV File",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep", "Separator",
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ","),
radioButtons("quote", "Quote",
choices = c(None = "",
"Double Quote" = '"',
"Single Quote" = "'"),
selected = '"'),
tags$hr(),
radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head"),
downloadButton("downloadData", "Download")
),
mainPanel(
# plotOutput('plot'),
tableOutput("selected_var")
)
)
server <- function(input, output) {
data <- reactive({
req(input$file1)
test1 <- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
test1[is.na(test1)] <- "0"
return(list(df = test1))
})
output$selected_var <- renderTable(data()$df)
}
shinyApp(ui = ui, server = server)
`