【发布时间】:2020-09-08 08:47:29
【问题描述】:
上传文件 1 时出现错误“无效的下标类型 'list'”
audi
chevrolet
dodge
ford
hyundai
我需要根据 file1 打印所有行。我的闪亮代码如下
library(shiny)
ui <- fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv"))),
mainPanel(
tableOutput("contents"))))
server <- function(input, output) {
output$contents <- renderTable({
req(input$file1)
data <- as.matrix(mpg)
df <- read.csv(input$file1$datapath)
data[df,]})}
shinyApp(ui, server)
【问题讨论】:
-
您正在制作的对象
df是一个数据框。然后,您尝试使用数据框对矩阵进行子集化,但这是行不通的。为此,df必须是您要提取的行名向量或行号向量。 -
我使用了 df
-
可以发一下
mpg的内容吗? -
来自ggplot2的mpg
标签: shiny