Skip to content

Error in get(i, parent.frame()) : object 'weights' not found #373

@fg-sempre

Description

@fg-sempre

Error description

When I try to use non-standard evaluation with box the following error occurs.

R/mod.R

box::use(
  blme,
  rlang,
)

#' @export
fit_w <- function(tbl, resp, w_form) {
  form <- paste0(resp, " ~ disp + (1|cyl)")

  blme$blmer(
    form,
    weights = !!as.name(w_form),
    data = tbl
  ) |>
    rlang$quo() |>
    rlang$eval_tidy()
}

main.R

box::use(R / mod)

mod$fit_w(mtcars, "mpg", "hp")

Error in get(i, parent.frame()) : object 'weights' not found

The same happens with lme4::lmer. When I replace box::use(R/mod) with source("R/mod.R") everything works fine.

R version

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          3.3                         
year           2024                        
month          02                          
day            29                          
svn rev        86002                       
language       R                           
version.string R version 4.3.3 (2024-02-29)
nickname       Angel Food Cake

‘box’ version

'1.2.0'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions