I have tried to use reticulate (v 1.18) so I can do both R (4.0.3) and python (3.8) in a rmd for data analysis.
I can run python code when using the "Run" button, but when I try to knit my Rmd to a html file.
It stucked, with a message like this below.
|.......... | 14%
ordinary text without R code
|.................... | 29%
label: setup
|.............................. | 43%
ordinary text without R code
|........................................ | 57%
label: unnamed-chunk-1 (with options)
List of 1
$ engine: chr "python"
I also tried to replace the reticulate engine by doing this
knitr::opts_chunk$set(python.reticulate=FALSE)
And it gave me error in my second python chunk (I also import pandas in the first python chunk).
If I don't use reticulate python engine, I think to remove the error is to import python module in every single python chunk....
"NameError: name 'pd' is not defined"
Calls: <Anonymous> ... call_block -> block_exec -> in_dir -> engine -> eng_interpreted
In addition: Warning message:
Execution halted
Is there any way to fix this which I can use reticulate ?
If I run all the chunks, it can print "ok", so it worked.
But when when I attempted to knit the Rmd to a html. The same problem occurred.
processing file: reticulate.Rmd
|.................. | 25%
ordinary text without R code
|................................... | 50%
label: setup
|.................................................... | 75%
ordinary text without R code
|......................................................................| 100%
label: unnamed-chunk-1 (with options)
List of 1
$ engine: chr "python"
It freezed with the message I attached previously at the line "engine: chr "python" when I clicked the "Knit" button, and there was not output.
Oh, the command rmarkdown::render("file.Rmd") you provided worked! I guess sth didn't work in the R studio GUI.
Yes, it's strange! Because of the error, I actually updated my RStudio and R yesterday.
My RStudio version is 1.3.1093. The previous version that I had is also just a few months old, as I usually update it every few month.