I have been tasked with running R and Knitr on an AWS Lambda (serverless computing) but since the folder structure of a Lambda is different, I'm having some issue with it.
This is have what I have so far (Lambda automatically calls my_function):
library(knitr)
?knit
my_function <- function() {
knit("./test.Rnw")
}
The error i'm getting is :
{
"errorMessage": "Error in file(file, ifelse(append, \"a\", \"w\")): cannot open the connection\n",
"errorType": "simpleError"
}
I'm almost certain it is related to how/where it is trying to output the file, I don't think there's anything wrong with the .Rnw file since it reaches 100% :
processing file: ./test.Rnw
|
| | 0%
|
|.................................................................| 100%
inline R code fragments
My question is, how can I change the output of Knitr, ideally also be able to check where it is trying to create the file? Or maybe just more info about the error.
Worth noting I'm a Python developer and have 0 knowledge of R/Knitr/Sweave/Latex/R-Markdown, all I'm trying it to get a Proof of Concept working.
The library tries to open the file in the 'w'
mode, while in the Lambda container the only writable file system partition is /tmp
. Please try to copy your file there first and then open.