简体   繁体   English

无法将数据从CSV文件读取到R Markdown闪亮文档

[英]Can't Read Data from CSV file to R Markdown Shiny Document

I am experimenting with the R Markdown Shiny documents for interactive reporting. 我正在尝试使用R Markdown Shiny文档进行交互式报告。 First trouble got is to read data from local csv file. 首先遇到的麻烦是从本地csv文件读取数据。

{r, cache=TRUE} raw1<-read.csv("data/set1.csv") splits <- unique(raw1$split) The error message I have is " Error in file(file, "rt") : cannot open the connection". {r, cache=TRUE} raw1<-read.csv("data/set1.csv") splits <- unique(raw1$split){r, cache=TRUE} raw1<-read.csv("data/set1.csv") splits <- unique(raw1$split)的错误消息是“ file(file,“ rt”)错误:不能打开连接”。

There is no issue to use the above code to read data in regular R Markdown documents. 使用上面的代码读取常规R Markdown文档中的数据没有问题。 Can anyone help the best practice to create interactive reporting using Shiny Document? 谁能帮助最佳实践使用Shiny Document创建交互式报告?

Try changing cache to FALSE. 尝试将缓存更改为FALSE。 I haven't been able to successfully use caching when hosting on a Shiny server. 在Shiny服务器上托管时,我无法成功使用缓存。

```{r, echo = FALSE, message=FALSE}
library(data.table)
dataset <- fread("yourfile.csv",header=T)
```

Try fread from data.table. 尝试从data.table中读取。 It should help. 应该会有所帮助。 Worked well for me. 对我来说很好。 It's also way faster than read.csv. 它也比read.csv更快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM