Skip to content

Instantly share code, notes, and snippets.

View MarkEdmondson1234's full-sized avatar
🦑
Tappity tap tap

Mark Edmondson MarkEdmondson1234

🦑
Tappity tap tap
View GitHub Profile
@MarkEdmondson1234
MarkEdmondson1234 / google_analytics_bigquery_user_mapping_table_customer.sql
Last active October 12, 2021 07:50 — forked from krisjan-oldekamp/google_analytics_bigquery_user_mapping_table_customer.sql
How to create a user mapping table (or Identity Graph) based on all the available user identifiers in the Google Analytics 4 BigQuery exports (like device-IDs or customer-IDs). Full article on stacktonic.com
-- Author: Krisjan Oldekamp
-- https://stacktonic.com/article/create-a-user-mapping-table-based-on-the-google-analytics-4-big-query-dataset
DECLARE
lookback_window INT64 DEFAULT 90; -- How many days to lookback into the dataset to search for IDs (compared to today)
-- Deduplicate array of struct
CREATE TEMP FUNCTION
DEDUP(val ANY TYPE) AS ((
SELECT
ARRAY_AGG(t)
FROM (
# This example demonstrates running furrr code distributed on 2 AWS instances ("nodes").
# The instances have already been created.
library(future)
library(furrr)
# Two t2.micro AWS instances
# Created from http://www.louisaslett.com/RStudio_AMI/
public_ip <- c("34.205.155.182", "34.201.26.217")
library("RSiteCatalyst")
library("dplyr")
SCAuth("peter.meyer@xxx.com:xxx", "xxx")
reportSuites <- GetReportSuites()
evar <- GetEvars(reportSuites$rsid) #%>%
# reportSuite <- reportSuites$rsid
@MarkEdmondson1234
MarkEdmondson1234 / global.R
Created December 1, 2017 16:39 — forked from raymondben/global.R
gauth shiny example
library(googleAuthR)
library(shiny)
library(shinyjs)
@MarkEdmondson1234
MarkEdmondson1234 / app.R
Last active March 14, 2024 15:42 — forked from jcheng5/app.R
Using OAuth2 with Shiny
library(shiny)
# WARNING: This sketch does not make proper use of the "state" parameter.
# Doing so usually involves using cookies, which can be done with the
# Rook package but I have not done that here. If you choose to use this
# approach in production, please check the state parameter properly!
APP_URL <- if (interactive()) {
# This might be useful for local development. If not, just hardcode APP_URL
# to the deployed URL that you'll provide a few lines below.
@MarkEdmondson1234
MarkEdmondson1234 / knit_cloudstorage.rmd
Created April 21, 2017 07:53 — forked from mwhitaker/knit_cloudstorage.rmd
Use googleCloudStorageR to automatically upload to Cloud Storage
---
title: "Host image files on Google Cloud storage"
author: "Michael Whitaker"
date: "January 12, 2017"
output:
html_document:
self_contained: false
---
```{r setup, include=FALSE}
# devtools::install_github("hrbrmstr/vegalite")
library(vegalite)
library(htmltools)
dat <- jsonlite::fromJSON('[
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
]')
library(idbr) # devtools::install_github('walkerke/idbr')
library(ggplot2)
library(animation)
library(dplyr)
library(ggthemes)
idb_api_key("Your Census API key goes here")
male <- idb1('JA', 2010:2050, sex = 'male') %>%
mutate(POP = POP * -1,
@MarkEdmondson1234
MarkEdmondson1234 / costdata.gs
Created February 15, 2016 14:15 — forked from chipoglesby/costdata.gs
Cost Data Upload via Google Analytic's Management API with Google Sheets
function uploadData() {
var accountId = "xxxxxxxx";
var webPropertyId = "UA-xxxxxxxx-x";
var customDataSourceId = "xxxxxxxx";
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var maxRows = ss.getLastRow();
var maxColumns = ss.getLastColumn();
var data = [];
for (var i = 1; i < maxRows;i++) {
data.push(ss.getRange([i], 1,1, maxColumns).getValues());
@MarkEdmondson1234
MarkEdmondson1234 / animate.R
Created February 8, 2016 22:34 — forked from thomasp85/animate.R
Animating graph over time
library(ggraph)
library(gganimate)
library(igraph)
# Data from http://konect.uni-koblenz.de/networks/sociopatterns-infectious
infect <- read.table('out.sociopatterns-infectious', skip = 2, sep = ' ', stringsAsFactors = FALSE)
infect$V3 <- NULL
names(infect) <- c('from', 'to', 'time')
infect$timebins <- as.numeric(cut(infect$time, breaks = 100))
# We want that nice fading effect so we need to add extra data for the trailing