Open rdstern opened 6 months ago
@rdstern Thank you for the scripts. If anyone finds a script that fails in R-Instat, then it's usually best to first test the script in RStudio. If it fails in RStudio then it's likely a script issue rather than an R-Instat issue. If it runs in RStudio but not in R-Instat, then it would be helpful to provide a screenshot of the R-Instat error(s). I tried to run the scripts in RStudio and they both failed. Normally, I would ask if you or @lilyclements could get these scripts to work in RStudio, and if they still failed in R-Instat, then I would investigate further.
However, I was curious and tried the scripts in R-Instat. Surprisingly, they ran better in R-Instat than RStudio. I assume that my R-Instat R environment must be slightly different to my RStudio R environment.
Script 1
I got the following error:
R-Instat is correct to report this error because the md
function currently in scope requires a y
parameter:
If we remove the md
function then the whole of script 1 runs correctly.
So in summary, I don't think there's anything I need to fix in R-Instat for script 1.
Script 2
As you said, R-Instat defines the function correctly.
However, it cannot parse the function call. Specifically it cannot parse the highlighted text below.
@lilyclements Do you know what the highlighted parts do and specifically what \
does? Is this valid R that we need to be able to parse in R-Instat?
Thanks for your help
@rdstern
For the second script, was there also a potential issue copying/pasting from the website?
For example !
is changed to !!
and the pipe symbol looks strange:
@lloyddewit thank you very much for the detective work. The md was the big one, because it happened regularly. This is now solved. And I should have guessed!
a) Another clue that there was going to be an obvious solution was that I couldn't find evidence on the web that others had trouble with this function.
b) The answer is that R-Instat (and our version of RStudio) must have another package that also has an md
command and that we load before the gt package. I can't find which package it is. But - in hindsight of course - that is an obvious possibility.
One solution is to put gt::md( ), each time. But running md <- gt::md
once is also sufficient. Then we can leave the resulting code as it is. That's ok (once you know) and is like having to include the library(gt)
command in a script.
@lloyddewit the first one seems logical as perhaps something that hasn't yet been implemented. This is an introductrion to the impressive gt package. The script uses the md(_) function, which handles markdown. That gives an error.
I have given the whole script here. It is from here, where you go to the getting started tab. It also shows the results. The one use of md remaining is about line 50. There were more instances, (about line 100) but they have been commented out.
The second is also from the gt package and is the one on clinical trials.. It defines and then tries to use a function. It seems to run, defining it, but gives an error when using it?
Here is the script:
The first part, which presumably produces the custom_summary function seems to run ok. The second part uses the custom_summary function and gives an error. I get the same strange error if I just type custom_summary.
I am not quite sure what it is doing here? It is @lilyclements sort of R, rather than mine!