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
# Example functions that would be in seperate files in the R directory of the package | |
simpleFn1 <- function(a){ | |
myConst <- 10 | |
a*myConst | |
} | |
simpleFn2 <- function(a){ | |
myConst <- 5 | |
a/myConst | |
} |
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(Rcpp) | |
cppFunction('double rate(double nper, double pmt, double pv){ | |
float rate1 = 0.01 ; | |
float rate2 = 0.05 ; | |
float newrate = 0 ; | |
int n = 10; | |
for (int i = 0; i < n; ++i) { | |
double pv1 = floor((-pmt/rate1 * (1 - 1/pow((1 + rate1),nper)))*100+0.5)/100 - pv ; | |
double pv2 = floor((-pmt/rate2 * (1 - 1/pow((1 + rate2),nper)))*100+0.5)/100 - pv ; | |
if (pv1 != pv2) { |
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
# Source of origpostcodedata data: https://geoportal.statistics.gov.uk/geoportal/catalog/search/resource/details.page?uuid=%7BD14C75CE-95C6-4E9F-8753-ECDD88BC2B7D%7D | |
# Source of postcodefiles data:https://www.ordnancesurvey.co.uk/opendatadownload/products.html | |
library(foreach) | |
library(data.table) | |
setwd("~") | |
postcodefiles<-dir("../Downloads/codepo_gb/Data//CSV/",full.names = TRUE) | |
# Slim load of 2.5m records into memory with f(ast)Read function | |
origpostcodedata<-fread("../Downloads/ONSPD_MAY_2013_csv/Data//ONSPD_MAY_2013_UK_O.csv", | |
select=c("pcd","pcd2","pcds","dointr", |
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
# This script will work for any SQL Saturday where schedule has not been confirmed (not tested on others!) just change the URL | |
library(rvest) | |
library(data.table) | |
library(ggplot2) | |
#wordcloud only required packages | |
library(wordcloud) | |
library(tm) | |
library(foreach) |
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
#Const LateBind = True | |
Function RegExpSubstitute(ReplaceIn, _ | |
ReplaceWhat As String, ReplaceWith As String) | |
#If Not LateBind Then | |
Dim RE As RegExp | |
Set RE = New RegExp | |
#Else | |
Dim RE As Object | |
Set RE = CreateObject("vbscript.regexp") | |
#End If |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:template match="/"> | |
<html> | |
<body> | |
<h2>Iris</h2> | |
<table border="1"> | |
<tr bgcolor="#9acd32"> | |
<th style="text-align:left">Sepal.Length</th> |
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
Title (max 60 characters) | |
------ | |
Short description (Quick sell! max 135 characters) | |
------ | |
Medium description (Sell & outline some content. max 100 words) | |
------ | |
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(data.table) | |
orig_subset<-function(workingdata){ | |
workingdata[["inputs"]][Species!='virginica'] | |
} | |
orig_mult<-function(workingdata){ | |
workingdata[["subset"]][,.SD*1.1,by=Species] | |
} |
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(data.table) | |
library(chron) | |
library(ggplot2) | |
library(stringr) | |
# This doesn't cope with spaces in URLs grr!! | |
url_pattern <- "http[s]?://(?:[@blank:]|[a-zA-Z]|[0-9]|[$-_@.&+ ]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+" | |
## Read data in from a text file | |
raw.log <- data.table(scan("bloblog.txt", character(0), 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
R_USER = "E:/Dropbox/hobbies/R" |
OlderNewer