# Substitute a bare expression in all call stack envs
substitute_stack <- function(expr) {
substitute_stack_q(substitute(expr))
}
# Substitute a quoted expression in all call stack envs
substitute_stack_q <- function(expr) {
envs <- sys.frames() # call stack
for (e in rev(envs)) {An answer to this closed StackOverflow question about reversing a time axis in ggplot2.
date = c("2011-11-15", "2011-11-16", "2011-11-17", "2011-11-19")
start = c("12:01:27", "12:01:25", "12:01:02", "12:01:12")
end = c("12:30:15", "12:32:15", "12:39:12", "12:30:18")
df = data.frame(date = as.POSIXct(date),
ystart = as.POSIXct(start, format="%H:%M:%S"),
yend = as.POSIXct(end, format="%H:%M:%S"),
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
| set.seed(1) | |
| n <- 1000 | |
| matrices <- replicate(n, matrix(runif(24 ^ 2), nrow = 24)) | |
| str(matrices) | |
| #> num [1:24, 1:24, 1:1000] 0.266 0.372 0.573 0.908 0.202 ... | |
| f <- function(x) { | |
| sum_x <- sum(x) | |
| if (sum_x == 0) |
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(tidyverse) | |
| library(rlang) | |
| complete_count <- function(.data, ...) { | |
| UseMethod("complete_count") | |
| } | |
| complete_count.grouped_df <- function(.data, ...) { | |
| grps <- groups(.data) | |
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
| #!/usr/bin/env python3 | |
| # -*- encoding: utf-8 -*- | |
| ''' | |
| Simple OLS with Python | |
| Fitting a simple OLS regression model using linear algebra with Python, | |
| following the first Matlab programming excercise for Machine Learning. | |
| Author: |
NewerOlder