Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression as actual expression (with environment) or quosure? #2

Open
joethorley opened this issue Feb 21, 2018 · 3 comments
Open
Assignees

Comments

@joethorley
Copy link
Member

joethorley commented Feb 21, 2018

@joethorley
Copy link
Member Author

This was reraised during MCMC athon and is now a priority.

@joethorley
Copy link
Member Author

Need to retain ability to work with old strings.

@krlmlr krlmlr self-assigned this May 23, 2023
@krlmlr
Copy link
Contributor

krlmlr commented May 25, 2023

Reprex to see which code is seeing new_expr :

options(conflicts.policy = list(warn = FALSE))
devtools::load_all(".")
#> ℹ Loading mcmcrtesting

sbf_set_sub("count")
analysis <- sbf_load_object("analysis")
#> Registered S3 method overwritten by 'rjags':
#>   method               from 
#>   as.mcmc.list.mcarray mcmcr
sbf_load_datas()

# slow part appears to be under within.list | eval | res_gamma_pois
# cbind/vectorized with residual ----
# this is fast and getting to where we want

mcmc_derive_data(
  analysis,
  new_data = data,
  new_expr = "
    rlang::abort('Just for testing')
    log(eCount) <- b0 + bYear * Year + bKelpLine * KelpLine + bSite[Site] + bAnnual[Annual] + bSiteAnnual[cbind(Site, Annual)]
    log(eCountKelpline) <- b0 + bKelpLine + bYear * Year + bAnnual[Annual] + bSite[Site] + bSiteAnnual[cbind(Site,Annual)]
    log(eCountBarren) <- b0 + bYear * Year + bAnnual[Annual] + bSite[Site] + bSiteAnnual[cbind(Site,Annual)]
    prediction <- eCountKelpline * 0.25 + eCountBarren * 0.75

    residual <- res_gamma_pois(Count, fit, sSiteAnnualQuadrat)
"
)
#> Error:
#> ! Just for testing
#> Backtrace:
#>      ▆
#>   1. ├─mcmcdata::mcmc_derive_data(analysis, new_data = data, new_expr = "\n    rlang::abort('Just for testing')\n    log(eCount) <- b0 + bYear * Year + bKelpLine * KelpLine + bSite[Site] + bAnnual[Annual] + bSiteAnnual[cbind(Site, Annual)]\n    log(eCountKelpline) <- b0 + bKelpLine + bYear * Year + bAnnual[Annual] + bSite[Site] + bSiteAnnual[cbind(Site,Annual)]\n    log(eCountBarren) <- b0 + bYear * Year + bAnnual[Annual] + bSite[Site] + bSiteAnnual[cbind(Site,Annual)]\n    prediction <- eCountKelpline * 0.25 + eCountBarren * 0.75\n\n    residual <- res_gamma_pois(Count, fit, sSiteAnnualQuadrat)\n")
#>   2. └─mbr:::mcmc_derive_data.mb_analysis(...)
#>   3.   ├─mcmcderive::mcmc_derive(...)
#>   4.   └─mbr:::mcmc_derive.mb_analysis(...) at mcmcderive/R/mcmc-derive.R:34:2
#>   5.     └─mbr:::mcmc_derive_fun(...)
#>   6.       ├─mcmcderive::mcmc_derive(...)
#>   7.       └─mcmcderive:::mcmc_derive.mcmcr(...) at mcmcderive/R/mcmc-derive.R:34:2
#>   8.         └─mcmcderive:::split_apply_combine(...) at mcmcderive/R/mcmc-derive.R:117:2
#>   9.           └─base::lapply(...) at mcmcderive/R/internal.R:167:4
#>  10.             └─mcmcderive (local) FUN(X[[i]], ...)
#>  11.               └─base::lapply(...) at mcmcderive/R/internal.R:146:2
#>  12.                 └─mcmcderive (local) FUN(X[[i]], ...)
#>  13.                   ├─base::within(object, eval(expr)) at mcmcderive/R/internal.R:137:2
#>  14.                   └─base::within.list(object, eval(expr))
#>  15.                     └─base::eval(substitute(expr), e)
#>  16.                       └─base::eval(substitute(expr), e)
#>  17.                         ├─base::eval(expr)
#>  18.                         │ └─base::eval(expr)
#>  19.                         └─rlang::abort("Just for testing")

Created on 2023-05-25 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants