r - Why does data table print inside an if block? -
why happen?
library(data.table) library(plyr) # revalue set.seed(123098) my_table <- data.table(x=1:10, str=sample(letters[1:4], 10, replace=t)) my_table[, y := 3*x + runif(nrow(my_table))] # runs silently mapping <- c("a"="andrew", "b"="barbarian", "c"="constant", "d"="deft") my_table[, new_str := revalue(str, replace=mapping)] # runs silently some_condition <- true if(some_condition) { my_table[, y := 3*x + runif(nrow(my_table))] # runs silently my_table[, new_str := revalue(str, replace=mapping)] # why print? } notice second call new_str := revalue(str, replace=mapping) -- on machine causes data table print. in little example doesn't matter much, have r script operating on large data table, , i'd rather not have unneeded printouts in logs. why happen , how can stop it?
edit: in case helpful:
$ r --version r version 3.0.2 (2013-09-25) -- "frisbee sailing" copyright (c) 2013 r foundation statistical computing platform: x86_64-pc-linux-gnu (64-bit) and r session:
> sessioninfo() r version 3.0.2 (2013-09-25) platform: x86_64-pc-linux-gnu (64-bit) locale: [1] lc_ctype=en_us.utf-8 lc_numeric=c [3] lc_time=en_us.utf-8 lc_collate=en_us.utf-8 [5] lc_monetary=en_us.utf-8 lc_messages=en_us.utf-8 [7] lc_paper=en_us.utf-8 lc_name=c [9] lc_address=c lc_telephone=c [11] lc_measurement=en_us.utf-8 lc_identification=c attached base packages: [1] stats graphics grdevices utils datasets methods base other attached packages: [1] plyr_1.8.1 data.table_1.9.4 loaded via namespace (and not attached): [1] chron_2.3-45 rcpp_0.11.3 reshape2_1.4 stringr_0.6.2
Comments
Post a Comment