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
library(DBI) | |
library(dbplyr) | |
suppressPackageStartupMessages(library(dplyr)) | |
#> Warning: package 'dplyr' was built under R version 3.4.1 | |
options(tibble.width = Inf) | |
cn <- dbConnect(odbc::odbc(), dsn = "access-odbc") | |
#dbListTables(cn) |
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
library(rlang) | |
library(tibble, warn.conflicts = FALSE) | |
# A formula for the cars dataset | |
f <- as.formula("speed ~ dist") | |
f | |
#> speed ~ dist | |
#> <environment: 0x7f8399800d80> | |
# X |
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
# Just an example "vector of means" | |
vec_of_means <- c(6.4, 2, 3.3, 4.6, 5, 8) | |
n <- length(vec_of_means) | |
# Loops! | |
for(i in 1:(n-1)) { | |
print(paste0("Hello i: ", vec_of_means[i], " ===")) | |
for(j in (i+1):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
# devtools::install_github("business-science/tibbletime") | |
library(tibbletime) | |
#> | |
#> Attaching package: 'tibbletime' | |
#> The following object is masked from 'package:stats': | |
#> | |
#> filter | |
library(tidyverse) | |
#> Loading tidyverse: ggplot2 | |
#> Loading tidyverse: tibble |
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(xtensor)]] | |
#include <numeric> | |
#include "xtensor/xmath.hpp" | |
#include "xtensor-r/rarray.hpp" | |
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::plugins(cpp14)]] |
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
db_write_table.ACCESS <- function(con, table, types, values, | |
temporary = FALSE, ...) { | |
db_create_table(con, table, types, temporary = temporary) | |
# Convert factors to strings | |
is_factor <- vapply(values, is.factor, logical(1)) | |
values[is_factor] <- lapply(values[is_factor], as.character) | |
# Encode special characters in strings |
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
suppressPackageStartupMessages(library(tibbletime)) | |
suppressPackageStartupMessages(library(dplyr)) | |
suppressPackageStartupMessages(library(purrr)) | |
# Create a tibble of event dates, ~100k | |
# 2013-01-01 to the end of the year by 5 minutes | |
event_dates <- create_series(~2013, 5~M, force_class = "POSIXct") | |
event_dates | |
#> # A time tibble: 105,120 x 1 |
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
``` r | |
library(odbc) | |
#> Warning: package 'odbc' was built under R version 3.4.2 | |
library(DBI) | |
con <- DBI::dbConnect(odbc::odbc(), | |
Driver = "PostgreSQL ODBC Driver(ANSI)", | |
Server = "localhost", | |
Database = "postgres", | |
UID = 'postgres', |
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
``` r | |
library(tibbletime) | |
library(dplyr) | |
options(digits.secs = 6) | |
# 1000 values | |
ex <- create_series('2013' ~ '2013-01-01 00:00:00.999', period = "1 millisec") | |
# Random data |
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
library(tibbletime) | |
library(dplyr) | |
library(zoo) | |
data(FB) | |
window <- 6 | |
rolling_mean <- rollify(mean, window = window) | |
FB_roll <- FB %>% |
OlderNewer