Hello,
I am creating an RMarkdown that allows users to (1) upload a file , and (2) have R Markdown to process the uploaded file to generate a report. I set
options(shiny.maxRequestSize = 9999*1024^2)
in .Rprofile, so that file size is not an issue when uploading to shiny user interface, as mentioned in here and here.
Somehow, when the file size is large (e.g. > 200 MB), knitting the R Markdown spits error message (shown below), but no such issue when file is small (e.g., 1% random sample of the original file). Please note, there is no problem uploading the large-size file to the GUI, but the problem seems to occur when R Markdown trying to access the data (temp.csv, set in the YAML header) after the file (original_data.csv) is uploaded successfully.
Could anyone figure out the reason why? R version is 4.1.0, R Studio version is 1.4.1717, and reproducible codes are pasted below. Thanks so much.
Error message when using data.table::fread()
Error in fread(params$datainput) : File 'temp.csv' does not exist or is non-readable. getwd() == 'C:/Users/abc/MyFolder' Calls: <Anonymous" ... withCallingHandlers -> withVisible -> eval -> eval -> fread
Error message when using read.csv()
Error in file(file, "rt") : cannot open the connection Calls: ... withVisible -> eval -> eval -> read.csv -> read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'temp.csv': No such file or directory
Codes:
---
title: "TBD"
author: "TBD"
date: "TBD"
output:
bookdown::html_document2:
df_print: paged
params:
#=======================#
# Render Function: #
#=======================#
datainput:
input: file
label: 'Upload file:'
value: temp.csv
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE,
fig.width = 12, fig.height = 8)
## Load packages
library(data.table)
library(tidyverse)
library(shiny)
R Markdown
This is an R Markdown document.
temp <- fread(params$datainput)
# Same error occurs if using read.csv()
#temp <- read.csv(params$datainput)
dim(temp)