Skip to content

Instantly share code, notes, and snippets.

@kaneplusplus
kaneplusplus / glmnet-ref.r
Last active January 17, 2016 20:40
A minimal glmnet implementation in R
soft_thresh = function(x, g) {
x = as.vector(x)
w1 = which(g >= abs(x))
w2 = which(g < abs(x) & x > 0)
w3 = which(g < abs(x) & x < 0)
ret = x
ret[w1] = 0
ret[w2] = x[w2]-g
ret[w3] = x[w3]+g
ret
@timelyportfolio
timelyportfolio / Readme.md
Last active August 29, 2015 14:03
rCharts + d3pie chart of US Beer
@doobwa
doobwa / example.openmp.r
Created February 1, 2012 05:35
OpenMP Rcpp example
#!/usr/bin/r
library(inline)
library(rbenchmark)
## openMPCode example from Rcpp/examples/OpenMP/ by Dirk E.
openMPCode <- '
// assign to C++ vector
std::vector<double> x = Rcpp::as<std::vector< double > >(xs);