This file contains 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 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 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 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 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 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
df <- data.frame(x=1) | |
x <- capture.output(.Internal(inspect(df))) | |
names(df) <- "a" | |
y <- capture.output(.Internal(inspect(df))) | |
internal_diff <- function(x, y) { | |
xp <- file.path( tempdir(), "Rdiff1.txt" ) | |
yp <- file.path( tempdir(), "Rdiff2.txt" ) | |
cat(x, file=xp, sep="\n") | |
cat(y, file=yp, sep="\n") |
This file contains 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
for (package in installed.packages()[, 1]) | |
library(package, character.only = TRUE) | |
ns <- search() | |
output <- vector("list", length(ns)) | |
for (i in seq_along(output)) { | |
namespace <- ns[[i]] | |
env <- as.environment(namespace) | |
objs <- mget( | |
objects(envir = env), |
This file contains 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
if (!require(httr)) { | |
devtools::install_github("httr") | |
library(httr) | |
} | |
get_archived_packages <- function(package, repo, where) { | |
archive <- file.path(repo, "Archive", package) | |
response <- httr::GET(archive) | |
if (response$status_code == "404") | |
stop("Could not access page at '", archive, "'.") |
This file contains 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
otool <- Sys.which("otool") | |
if (otool == "") { | |
stop("This utility requires 'otool' to run") | |
} | |
allPackages <- list.files(.libPaths(), full.names = TRUE) | |
stdLibsUsed <- lapply(allPackages, function(path) { | |
pkgName <- basename(path) | |
libPath <- file.path(path, "libs", paste0(pkgName, ".so")) | |
if (!file.exists(libPath)) { |
This file contains 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
setGeneric("plot", function(x, ...) { | |
standardGeneric("plot") | |
}) | |
setMethod("plot", list(x = "ANY"), function(x, ...) { | |
UseMethod("plot") | |
}) |
OlderNewer