This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Jitter-dodge points to align them with a boxplot including fill aesthetic | |
#' | |
#' @family position adjustments | |
#' @param width degree of jitter in x direction. Defaults to 40\% of the | |
#' resolution of the data. | |
#' @param height degree of jitter in y direction. Defaults to 40\% of the | |
#' resolution of the data | |
#' @export | |
#' @examples | |
#' dsub <- diamonds[ sample(1:nrow(diamonds), 1000), ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [[Rcpp::depends(RcppGSL)]] | |
#include <gsl/gsl_randist.h> | |
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
NumericVector gsl_dexp(NumericVector x) { | |
int n = x.size(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`|` <- function(x, y) { | |
if (is.data.frame(x)) { | |
return( eval(call("%.%", substitute(x), substitute(y)), envir=parent.frame()) ) | |
} else { | |
return( base::"|"(x, y) ) | |
} | |
} | |
library(dplyr) | |
mtcars | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run me by installing Rcpp and calling sourceCpp on this file | |
#include <Rcpp.h> | |
using namespace Rcpp; | |
// some initial stuff borrowed from R sources | |
#ifdef WORDS_BIGENDIAN | |
static const int hw = 0; | |
static const int lw = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case2 <- function(n = 10, mu = 3, sigma = sqrt(5), p = 0.025, rep = 100){ | |
xbar <- vapply(1:rep, FUN.VALUE=numeric(1), function(i) { | |
norm <- rnorm(mean = mu, sd = sigma, n = n) | |
return(mean(norm)) | |
}) | |
low <- xbar - qnorm(1-p) * (sigma / sqrt(n)) | |
up <- xbar + qnorm(1-p) * (sigma / sqrt(n)) | |
rem <- mu > low & mu < up |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_status <- '' | |
class(git_status) <- "__git_status__" | |
print.__git_status__ <- function(x, ...) system("git status") | |
git_status ## prints 'git status' for the current dir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code copied and modified from the R sources (src/main/apply.c) for do_lapply. | |
// Essentially, we remove some of the op / arity checking, and then | |
// construct a call to FUN that also passes the index. | |
#define USE_RINTERNALS | |
#include <R.h> | |
#include <Rinternals.h> | |
// [[export]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Rcpp.h> | |
using namespace Rcpp; | |
union DoublePunner { | |
double d; | |
uint64_t p; | |
}; | |
static DoublePunner NA_PUNNED = { NA_REAL }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define debug | |
#ifdef DEBUG | |
#define debug(x) Rprintf(x) | |
#define debug2(x, y) Rprintf(x, y) | |
#define debug3(x, y, z) Rprintf(x, y, z) | |
#else | |
#define debug(x) | |
#define debug2(x, y) | |
#define debug3(x, y, z) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer( function(input, output, session) { | |
}) |