Skip to content

Instantly share code, notes, and snippets.

View grayskripko's full-sized avatar
🏠
Working from home

Gray grayskripko

🏠
Working from home
  • Buenos Aires, Argentina
View GitHub Profile
> winCmd <- 'R -q -e "11+1; 1+undef_var; 12+2"'
> pp <- pipe(winCmd, open='r')
> readLines(pp) # does not return any error message and freezes
[1] "> 11+1; 1+undef_var; 12+2" "[1] 12"
> close(pp)
> winCmd <- 'R -q -e "11+1; 1+undef_var; 12+2" 2>&1'
> pp <- pipe(winCmd, open='r')
> readLines(pp) # works fine
[1] "> 11+1; 1+undef_var; 12+2" "[1] 12"
> ls()
character(0)
> foo <- function() list(a=1, b=2)
> invisible(list2env(foo(), envir = environment()))
> ls()
[1] "a" "b" "foo"
> rm(list=ls())
> foo <- function() list(1, 2)
> invisible(list2env(mapply(assign, c('c', 'd'), foo(), SIMPLIFY = F), envir=environment()))
registerDoParallel(cores=2)
rf.mod <- foreach(ntree=rep(500, 6), .combine=combine, .multicombine=TRUE,
.packages='randomForest') %dopar% {
randomForest(ЗДЕСЬКАКОБЫЧНО)
}
object_size(stat) * 2**30 / nrow(stat) / ncol(stat) # 8.59
2**30 / 8.59 # 125 * 1e6
nrow(X) * ncol(X) / 125 / 1e6 # 80 Gb
methods('format')
getAnywhere('format.facet') # == ggplot2:::format.facet
class(dtm)
[1] "TermDocumentMatrix" "simple_triplet_matrix"
getAnywhere(as.matrix.simple_triplet_matrix)
@grayskripko
grayskripko / R_export_registerDoSEQ.txt
Created June 22, 2017 14:59
object ‘registerDoSEQ’ is not exported by 'namespace:doParallel'
foreach::registerDoSEQ
@grayskripko
grayskripko / 340_bug.txt
Created June 27, 2017 10:38
missing value where TRUE/FALSE needed, devtools install, Windows 10, R 3.4.0
Patch for Windows https://cran.r-project.org/bin/windows/base/rtest.html
Otherwise you can close all file explorer windows :)
This bug appeares when R tryes to get modification date for C:\Users\<SomeUser>\Documents\R\win-library\3.4 folder (my case).
More precisely for one of .libPaths()
For R 3.4.0 it can be NA for an open folder (open = locked by another process). NA in if() gives the error
@grayskripko
grayskripko / install_could_not_find_build_tools.txt
Last active July 19, 2017 23:14
Devtools::install_github() Installation failed: Could not find build tools necessary to build catboost
Just rerun the previous command one more time
@grayskripko
grayskripko / trim_list.txt
Created July 20, 2017 11:31
Trim a list with NULLs
list(a=1, b=if (F) 2) %>% Filter(function(x) !is.null(x), .)
@grayskripko
grayskripko / multiple_actual_args.txt
Last active July 20, 2017 15:57
caret: Error in method$fit ... formal argument <some_name> matched by multiple actual arguments
debug(caret::createModel)
pay attention to model$fit: https://github.com/topepo/caret/blob/master/pkg/caret/R/createModel.R#L46
If <some_name> == 'param' and you use do.call(caret::train, arg_list), pass parameters in 'param' without list, as is.
Anyway, the important part of the stacktrace is:
1. caret::train.default
2. caret::createModel # <- the location of the problem
3. model$fit