0
我正在尝试一个非常基本的闪亮应用程序,并且出现错误! 我有一个简单的数据集txt文件10x10。 我可以R中轻松阅读它,函数read.table通过命令:阅读闪亮的应用程序中的文件
tb=read.table("Data.txt",sep="")
的出落得是:
V1 V2 V3 V4 V5 V6 V7 V8
1 -1.44736 -0.9583 -1.50346 0.12537 0.06332 1.81820 1.2510 0.5793
2 -0.08243 0.6896 0.91643 1.22713 1.30572 0.67108 -0.2496 0.2021
3 1.03049 1.3470 0.01859 -0.33945 -0.77241 -0.27944 0.2572 0.3229
4 0.96038 0.6042 1.26491 0.07691 0.84525 -0.97459 0.4324 0.8489
5 0.95835 -1.8923 -0.43028 0.57660 0.55485 -0.08226 0.4904 -0.2361
6 1.17600 -0.5480 -0.72248 -0.61439 -1.21602 0.70752 0.5765 1.1586
7 0.72957 -1.4862 2.33438 -1.09799 0.60963 0.26388 1.7796 1.3703
8 0.59776 0.9756 -1.47961 0.19636 -0.79520 0.02594 0.1004 0.1278
9 1.10021 -1.0643 0.12381 -0.96318 -0.52618 -0.56597 -0.6296 -0.5527
10 1.03680 -0.6139 0.30787 1.90541 -0.64111 1.28889 1.2670 0.9928
V9 V10
1 -1.20396 0.225245
2 -1.47926 0.881382
3 0.73340 -0.344852
4 -0.56226 -1.130889
5 0.95693 0.213951
6 -0.06354 1.260926
7 0.45870 0.894200
8 0.82496 -1.014504
9 0.19422 0.008162
10 0.29386 -0.318137
但是当我尝试做同样的闪亮:
library(shiny)
ui <- fluidPage(
fileInput("file","import file"),
tableOutput("tb")
)
server <- function(input,output){
output$tb <-renderTable({
data <- input$file
if(is.null(data)){return()}
read.table(data$path,sep="")
})
}
shinyApp(ui=ui, server=server)
浏览数据后出现以下错误:
'file' must be a character string or connection
我在我的闪亮应用程序中错过了什么?
你希望用户上传的文件,或者是否应该在应用程序启动进口? – Florian
@Florian用户上传文件 –