Skip to content

Instantly share code, notes, and snippets.

@dsparks
dsparks / advent_zoo.R
Created November 30, 2012 16:54
Rolling means with zoo
doInstall <- TRUE
toInstall <- c("zoo")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
ftseIndex <- EuStockMarkets[, 4]
plot(ftseIndex, col = "GRAY")
# Calculate 10-day rolling mean, quickly:
smoothIndex <- rollmean(x = ftseIndex, # original series
@ralfbecher
ralfbecher / QlikView_WeekName_to_Date.qvs
Created September 2, 2013 10:34
Converts a given weekname (eg. 2013/36) to the starting date of the week. Opposite of QlikView WeekName() function.
// Convert weekname (eg. format YYYY/WW) to date:
=MakeWeekDate(subfield(field, '/', 1), subfield(field, '/', 2), 0)
@ChrisBeeley
ChrisBeeley / server.R
Last active October 2, 2019 15:55
Demo to show widget types, return values and data types in Shiny
function(input, output) {
output$textDisplay <- renderTable({
getMat = matrix(
c(paste(input$checkGroup, collapse=','), class(input$checkGroup),
input$boxInput, class(input$boxInput),
as.character(as.Date(input$theDate, origin = "1970-01-01")), class(input$theDate),
paste(as.character(as.Date(input$dateRange[[1]], origin = "1970-01-01")),
as.character(as.Date(input$dateRange[[2]], origin = "1970-01-01")),
@stefanwalther
stefanwalther / QlikView_SaveTables_ToQVDs.qvs
Last active September 10, 2019 17:32
QlikView Script: Save all tables to QVD files.
// '.\' is the current path
// Define the path here, if required ...
SET basePath = '.\';
TRACE ---------------------------------------------------------------;
TRACE Saving tables ... ;
TRACE ~~;
For i = 0 To NoOfTables() -1
@benmarwick
benmarwick / PDF-2-text-or-CSV.r
Last active July 18, 2022 03:48
Convert PDFs to text files or CSV files (DfR format) with R
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
@jennybc
jennybc / 2015-03-02_plot-next-to-table.rmd
Last active June 30, 2022 19:46
Quicky and dirty: side-by-side plot and table
---
title: "Quicky and dirty: side-by-side plot and table"
author: "Omar AlOmeir"
output:
html_document:
css: two_columns.css
---
Code from Omar AlOmeir, posted by Jenny Bryan
@hadley
hadley / ds-training.md
Created March 13, 2015 18:49
My advise on what you need to do to become a data scientist...

If you were to give recommendations to your "little brother/sister" on things that they need to do to become a data scientist, what would those things be?

I think the "Data Science Venn Diagram" (http://drewconway.com/zia/2013/3/26/the-data-science-venn-diagram) is a great place to start. You need three things to be a good data scientist:

  • Statistical knowledge
  • Programming/hacking skills
  • Domain expertise

Statistical knowledge

@steadyfish
steadyfish / dplyr_functions_programmatic_use.R
Last active October 12, 2020 09:27
using dplyr functions programmatically
# using dplyr finctions in non-interactive mode
# examples
library(plyr)
library(dplyr)
d1 = data_frame(x = seq(1,20),y = rep(1:10,2),z = rep(1:5,4))
head(d1)
#### single table verbs ####
@mapsam
mapsam / README.md
Last active June 11, 2023 11:59
Namecheap > Github pages

Namecheap > Github pages

Pointing your domains to a gh-pages branch requires three steps.

  1. Add the Github IPs as A records on Namecheap.
    185.199.108.153
    185.199.109.153
    185.199.110.153
    185.199.111.153
@wdullaer
wdullaer / syntax.css
Created April 25, 2015 17:23
Monokai Syntax CSS theme
/* Adjusted to give override background and text colour */
.highlight pre, pre, .highlight .hll {
background-color: #49483E;
border: 1px solid #ccc;
padding: 6px 10px;
border-radius: 3px;
color: #FFFFFF;
}
.gist pre {