tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.
https://reprex.tidyverse.org
Other
741 stars 80 forks source link

Warning that R appears to crash when it does not #429

Closed billdenney closed 11 months ago

billdenney commented 1 year ago

When I run the below reprex, it indicates that R appears to have crashed when it did not.

Before running this, you must install the rxode2 and nlmixr2lib packages.

reprex::reprex({
library(nlmixr2lib)
library(rxode2)
modBase <-
  readModelDb("PK_1cmt") %>%
  model(
    cl <- exp(lcl + allo_cl*WT)
  ) %>%
  ini(
    allo_cl <- 0.75
  )

modBase %>%
  addEta("cl")
},
std_out_err = TRUE)

When run manually, this is the result:

> library(nlmixr2lib)
> library(rxode2)
> modBase <-
+   readModelDb("PK_1cmt") %>%
+   model(
+     cl <- exp(lcl + allo_cl*WT)
+   ) %>%
+   ini(
+     allo_cl <- 0.75
+   )
ℹ add covariate `allo_cl`
ℹ add covariate `WT`
ℹ promote `allo_cl` to population parameter with initial estimate 0.75
ℹ change initial estimate of `allo_cl` to `0.75`
> modBase %>%
+   addEta("cl")
ℹ parameter labels from comments are typically ignored in non-interactive mode
ℹ Need to run with the source intact to parse comments
rxode2 model syntax error:
================================================================================
:001: ka <- exp(lka)

rxode2 syntax error after '���o':
:002: cl + etacl <- exp(lcl + allo_cl * WT)
         ^
:002: vc <- exp(lvc)
:003: cp <- linCmt()
================================================================================
Error in rxModelVars_(obj) : Evaluation error: Evaluation error: rxode2 syntax error after '���o':
:002: cl + etacl <- exp(lcl + allo_cl * WT)   ^
more errors could be listed above..
> 

I assume that this has something to do with the unprintable characters.

hadley commented 11 months ago

This now seems fine, likely due to the fix in rxode2parse.