* using log directory 'd:/Rcompile/CRANpkg/local/4.6/bruceR.Rcheck' * using R Under development (unstable) (2025-12-23 r89222 ucrt) * using platform: x86_64-w64-mingw32 * R was compiled by gcc.exe (GCC) 14.3.0 GNU Fortran (GCC) 14.3.0 * running under: Windows Server 2022 x64 (build 20348) * using session charset: UTF-8 * checking for file 'bruceR/DESCRIPTION' ... OK * this is package 'bruceR' version '2025.11' * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking whether package 'bruceR' can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking code files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... [24s] OK * checking whether the package can be loaded with stated dependencies ... [24s] OK * checking whether the package can be unloaded cleanly ... [24s] OK * checking whether the namespace can be loaded with stated dependencies ... [1s] OK * checking whether the namespace can be unloaded cleanly ... [2s] OK * checking loading without being on the library search path ... [4s] OK * checking whether startup messages can be suppressed ... [23s] OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [12s] OK * checking Rd files ... [1s] OK * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of 'data' directory ... OK * checking data for non-ASCII characters ... [0s] OK * checking LazyData ... OK * checking data for ASCII and uncompressed saves ... OK * checking examples ... [11s] ERROR Running examples in 'bruceR-Ex.R' failed The error most likely occurred in: > ### Name: add > ### Title: Create, modify, and delete variables. > ### Aliases: add added > > ### ** Examples > > ## ====== Usage 1: add() ====== ## > > d = as.data.table(within.1) > d$XYZ = 1:8 > d ID A1 A2 A3 A4 XYZ 1: S1 3 4 8 9 1 2: S2 6 6 9 8 2 3: S3 4 4 8 8 3 4: S4 3 2 7 7 4 5: S5 5 4 5 12 5 6: S6 7 5 6 13 6 7: S7 5 3 7 12 7 8: S8 2 3 6 11 8 > > # add() does not change the raw data: > add(d, {B = 1; C = 2}) ID A1 A2 A3 A4 XYZ B C 1: S1 3 4 8 9 1 1 2 2: S2 6 6 9 8 2 1 2 3: S3 4 4 8 8 3 1 2 4: S4 3 2 7 7 4 1 2 5: S5 5 4 5 12 5 1 2 6: S6 7 5 6 13 6 1 2 7: S7 5 3 7 12 7 1 2 8: S8 2 3 6 11 8 1 2 > d ID A1 A2 A3 A4 XYZ 1: S1 3 4 8 9 1 2: S2 6 6 9 8 2 3: S3 4 4 8 8 3 4: S4 3 2 7 7 4 5: S5 5 4 5 12 5 6: S6 7 5 6 13 6 7: S7 5 3 7 12 7 8: S8 2 3 6 11 8 > > # new data should be assigned to an object: > d = d %>% add({ + ID = str_extract(ID, "\\d") # modify a variable + XYZ = NULL # delete a variable + A = .mean("A", 1:4) # create a new variable + B = A * 4 # new variable is immediately available + C = 1 # never need ,/; at the end of any line + }) > d ID A1 A2 A3 A4 A B C 1: 1 3 4 8 9 6.00 24 1 2: 2 6 6 9 8 7.25 29 1 3: 3 4 4 8 8 6.00 24 1 4: 4 3 2 7 7 4.75 19 1 5: 5 5 4 5 12 6.50 26 1 6: 6 7 5 6 13 7.75 31 1 7: 7 5 3 7 12 6.75 27 1 8: 8 2 3 6 11 5.50 22 1 > > > ## ====== Usage 2: added() ====== ## > > d = as.data.table(within.1) > d$XYZ = 1:8 > d ID A1 A2 A3 A4 XYZ 1: S1 3 4 8 9 1 2: S2 6 6 9 8 2 3: S3 4 4 8 8 3 4: S4 3 2 7 7 4 5: S5 5 4 5 12 5 6: S6 7 5 6 13 6 7: S7 5 3 7 12 7 8: S8 2 3 6 11 8 > > # added() has already changed the raw data: > added(d, {B = 1; C = 2}) > d ID A1 A2 A3 A4 XYZ B C 1: S1 3 4 8 9 1 1 2 2: S2 6 6 9 8 2 1 2 3: S3 4 4 8 8 3 1 2 4: S4 3 2 7 7 4 1 2 5: S5 5 4 5 12 5 1 2 6: S6 7 5 6 13 6 1 2 7: S7 5 3 7 12 7 1 2 8: S8 2 3 6 11 8 1 2 > > # raw data has already become the new data: > added(d, { + ID = str_extract(ID, "\\d") + XYZ = NULL + A = .mean("A", 1:4) + B = A * 4 + C = 1 + }) > d ID A1 A2 A3 A4 B C A 1: 1 3 4 8 9 24 1 6.00 2: 2 6 6 9 8 29 1 7.25 3: 3 4 4 8 8 24 1 6.00 4: 4 3 2 7 7 19 1 4.75 5: 5 5 4 5 12 26 1 6.50 6: 6 7 5 6 13 31 1 7.75 7: 7 5 3 7 12 27 1 6.75 8: 8 2 3 6 11 22 1 5.50 > > > ## ====== Using `when` and `by` ====== ## > > d = as.data.table(between.2) > d A B SCORE 1: 1 1 3 2: 1 1 6 3: 1 1 4 4: 1 1 3 5: 1 2 4 6: 1 2 6 7: 1 2 4 8: 1 2 2 9: 1 3 5 10: 1 3 7 11: 1 3 5 12: 1 3 2 13: 2 1 4 14: 2 1 5 15: 2 1 3 16: 2 1 3 17: 2 2 8 18: 2 2 9 19: 2 2 8 20: 2 2 7 21: 2 3 12 22: 2 3 13 23: 2 3 12 24: 2 3 11 A B SCORE > > added(d, {SCORE2 = SCORE - mean(SCORE)}, + A == 1 & B %in% 1:2, # `when`: for what conditions + by=B) # `by`: by what groups Error in `[.data.table`(data, A == 1 & B %in% 1:2, `:=`(SCORE2 = SCORE - : attempt access index 3/3 in VECTOR_ELT Calls: added -> eval -> eval -> [ -> [.data.table Execution halted * checking PDF version of manual ... [29s] OK * checking HTML version of manual ... [17s] OK * DONE Status: 1 ERROR