Intermittent " Error in `df_append()`" message

Hi,
I'm coming across an intermittent error message when trying to run the below code (codified from LexOPS package (Taylor et al, 2020)). I have searched the error message and, as it has been previously identified and seems to have been resolved as a bug, I'm now lost! If anyone please has any ideas, could direct me to the right place or do I need to report it as an internal error in github?

library(LexOPS)

stim <- LexOPS::lexops %>%
  full_join(custom_df, by = "string") %>%
  subset(custom.PoS.SUBTLEX_UK %in% c("noun")) %>%
  subset(custom.PK.Brysbaert >= 0.8 & custom.PK.Brysbaert <= 1) %>%
  subset(custom.Olfactory.mean >= 1 & custom.Olfactory.mean <= 5) %>%
  subset(custom.Visual.mean >= 1 & custom.Visual.mean <= 5) %>%
  subset(custom.VAL.Warriner >= 1.2 & custom.VAL.Warriner <= 8.6) %>%
  subset(custom.AROU.Warriner >= 2 & custom.AROU.Warriner <= 6) %>%
  split_by(custom.Dominant.percpetual.OG, "OG" ~ "Visual") %>%
  control_for(custom.Zipf.SUBTLEX_UK, -0.1:0.1) %>%
  control_for(custom.ON.OLD20, -0.2:0.2) %>%
  generate("all", "balanced", seed = 144689386)

Sometimes it works to generate the stimuli output directly from R (as opposed to the accompanying Shiny App), sometimes it doesn't and gives the following error message which asks me to report it in github:-

Error in df_append():
! after must be a whole number, not an integer NA.
:information_source: This is an internal error that was detected in the tidyr package.
Please report it at https://github.com/tidyverse/tidyr/issues with a reprex and the full backtrace.

Backtrace:

  1. ├─... %>% generate("all", "balanced", seed = 144689386)
  2. ├─LexOPS::generate(., "all", "balanced", seed = 144689386)
  3. │ └─... %>% dplyr::filter(!is.na(!!dplyr::sym(cond_col)))
  4. ├─dplyr::filter(., !is.na(!!dplyr::sym(cond_col)))
  5. ├─tidyr::unite(...)
  6. └─tidyr:::unite.data.frame(...)
  7. └─tidyr:::df_append(after = after)
  8. └─tidyr:::check_number_whole(after, min = 0L, max = n, .internal = TRUE)
    
  9.   └─tidyr:::.rlang_types_check_number(...)
    
  10.     └─tidyr (local) .stop(x, what, ...)
    
  11.       └─tidyr:::stop_input_type(...)
    
  12.         └─rlang::abort(message, ..., call = call, arg = arg)
    

I have attempted to run a reprex (apologies if this is not correct as it's my first time of doing this) I note here that it says the csv file does not exist but this loads this into my R environment as the custom_df element each time I run it (and I've checked it is the correct wd)


library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(readr)

custom_df <- read_csv("sens_lex_ops_og.csv") %>%
  rename(string = "word") %>%
  rename_at(vars(-"string"), ~ sprintf("custom.%s", .))
#> Error: 'sens_lex_ops_og.csv' does not exist in current working directory ('C:/Users/rowka/AppData/Local/Temp/Rtmpgn0lut/reprex-6d4473815cd9-neat-zebra').

library(LexOPS)

stim <- LexOPS::lexops %>%
  full_join(custom_df, by = "string") %>%
  subset(custom.PoS.SUBTLEX_UK %in% c("noun")) %>%
  subset(custom.PK.Brysbaert >= 0.8 & custom.PK.Brysbaert <= 1) %>%
  subset(custom.Olfactory.mean >= 1 & custom.Olfactory.mean <= 5) %>%
  subset(custom.Visual.mean >= 1 & custom.Visual.mean <= 5) %>%
  subset(custom.VAL.Warriner >= 1.2 & custom.VAL.Warriner <= 8.6) %>%
  subset(custom.AROU.Warriner >= 2 & custom.AROU.Warriner <= 6) %>%
  split_by(custom.Dominant.percpetual.OG, "OG" ~ "Visual") %>%
  control_for(custom.Zipf.SUBTLEX_UK, -0.1:0.1) %>%
  control_for(custom.ON.OLD20, -0.2:0.2) %>%
  generate("all", "balanced", seed = 144689386)
#> Error: object 'custom_df' not found

Created on 2024-10-07 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14 ucrt)
#>  os       Windows 11 x64 (build 22631)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United Kingdom.utf8
#>  ctype    English_United Kingdom.utf8
#>  tz       Europe/London
#>  date     2024-10-07
#>  pandoc   3.1.11 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  bit           4.5.0   2024-09-20 [1] CRAN (R 4.4.1)
#>  bit64         4.5.2   2024-09-22 [1] CRAN (R 4.4.1)
#>  cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.1)
#>  crayon        1.5.3   2024-06-20 [1] CRAN (R 4.4.1)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.1)
#>  dplyr       * 1.1.4   2023-11-17 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.0   2024-09-17 [1] CRAN (R 4.4.1)
#>  fansi         1.0.6   2023-12-08 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.1)
#>  fs            1.6.4   2024-04-25 [1] CRAN (R 4.4.1)
#>  generics      0.1.3   2022-07-05 [1] CRAN (R 4.4.1)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.1)
#>  hms           1.1.3   2023-03-21 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.1)
#>  knitr         1.48    2024-07-07 [1] CRAN (R 4.4.1)
#>  LexOPS      * 0.3.1   2024-08-18 [1] Github (JackEdTaylor/LexOPS@205400e)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.1)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.1)
#>  pillar        1.9.0   2023-03-22 [1] CRAN (R 4.4.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.4.1)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.1)
#>  readr       * 2.1.5   2024-01-10 [1] CRAN (R 4.4.1)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.4.1)
#>  rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.1)
#>  rmarkdown     2.28    2024-08-17 [1] CRAN (R 4.4.1)
#>  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.1)
#>  tibble        3.2.1   2023-03-20 [1] CRAN (R 4.4.1)
#>  tidyselect    1.2.1   2024-03-11 [1] CRAN (R 4.4.1)
#>  tzdb          0.4.0   2023-05-12 [1] CRAN (R 4.4.1)
#>  utf8          1.2.4   2023-10-22 [1] CRAN (R 4.4.1)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.1)
#>  vroom         1.6.5   2023-12-05 [1] CRAN (R 4.4.1)
#>  withr         3.0.1   2024-07-31 [1] CRAN (R 4.4.1)
#>  xfun          0.48    2024-10-03 [1] CRAN (R 4.4.1)
#>  yaml          2.3.10  2024-07-26 [1] CRAN (R 4.4.1)
#> 
#>  [1] C:/Users/rowka/AppData/Local/R/win-library/4.4
#>  [2] C:/Program Files/R/R-4.4.1/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

This is on purpose, when you run reprex() the working directory changes (if you ever really really need to overwrite that, you can use wd = "."). The problem with your current reprex is that we can't reproduce it without the csv file.

Are you able to share the csv that causes the problem? Do you get the same problem if you just run a small subset of the csv, for example if you run this:

custom_df <- read_csv("sens_lex_ops_og.csv") %>%
  rename(string = "word") %>%
  rename_at(vars(-"string"), ~ sprintf("custom.%s", .)) %>%
  head()

does the computation of stim give you the same error message? If so could you share the dput(custom_df) ? Paste between three backticks:

```
[paste code here]
```