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
# get the FX rates from Quandl | |
gbppln <- Quandl("CURRFX/GBPPLN") | |
# xts object for dygraphs | |
gbppln_xts <- Quandl("CURRFX/GBPPLN", type="xts") | |
# stl expects a time series data type | |
gbppln_ts <- Quandl("CURRFX/GBPPLN", | |
collapse="monthly", | |
type="ts") |
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
# change column names to R-friendly format | |
colnames(gbppln)[colnames(gbppln)=="High (est)"] <- "High_est" | |
colnames(gbppln)[colnames(gbppln)=="Low (est)"] <- "Low_est" | |
# change column names to R-friendly format | |
colnames(gbppln_xts)[colnames(gbppln_xts)=="High (est)"] <- "High_est" | |
colnames(gbppln_xts)[colnames(gbppln_xts)=="Low (est)"] <- "Low_est" | |
# remove the high/low estimates columns | |
gbppln_xts$High_est <- NULL |
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
# Reuters-like colours | |
# https://s3.amazonaws.com/quandl-static-content/Documents/Quandl+-+R+Cheat+Sheet.pdf | |
fx.plot <- ggplot(data = gbppln, aes(x=Date,y=Rate)) + | |
geom_line(color = "#FAB521")+ | |
theme(panel.background = element_rect(fill="#393939"), | |
panel.grid.major.x = element_blank(), | |
panel.grid.major.y = element_line(colour="white", size=0.1), | |
panel.grid.minor = element_line(colour="white", size=0.1)) + | |
xlab("Date") + | |
ylab("GBP/PLN") + |
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(AnomalyDetection) | |
library(dygraphs) | |
library(ggplot2) | |
library(lubridate) | |
library(magrittr) | |
library(Quandl) |
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
# run the anomaly detection | |
posixDate <- as.POSIXct(gbppln$Date) | |
gbppl_ad_df <- data.frame(posixDate, gbppln$Rate) | |
fx.ad <- AnomalyDetectionVec(gbppl_ad_df$gbppln.Rate, | |
max_anoms=0.05, | |
direction='both', | |
plot=TRUE, | |
period=30) | |
# plot the anomalies |
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
# install necessary packages | |
devtools::install_github("dvanclev/GTrendsR") | |
devtools::install_github("trinker/gtrend") | |
# load the packages | |
library(curl) | |
library(dplyr) | |
library(gtrend) | |
library(ggplot2) | |
library(ngramr) |
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
# analyse data about 2015 Polish parliamentary elections | |
# more info: http://smarterpoland.pl/index.php/2015/12/czy-internet-pozwala-przewidziec-wyniki-wyborow/ | |
library(Amelia) | |
library(ggplot2) | |
library(tabplot) | |
# load the data | |
dane <- read.table("https://raw.githubusercontent.com/pbiecek/SmarterPoland_blog/master/dane/Wybory2015/2r.txt", | |
header=T, | |
sep="\t", |
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
File type = "ooTextFile" | |
Object class = "Sound 2" | |
0 | |
0.41 | |
6536 | |
0.0000610221205187 | |
0.0000305110602593 | |
1 | |
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
txt2praat <- function(x, filename) { | |
# Appends the Praat header to enable txt vector to be read in Praat. | |
# | |
# Args: | |
# x: A path to the txt file (vector) that the header attached will be attached to. | |
# Example: | |
# >x <- file.choose() | |
# | |
# filename: Optional argument specifying the output file name | |
# |
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
# countries by the number of universities in the CWUR ranking | |
library(dplyr) | |
library(ggplot2) | |
library(RColorBrewer) | |
library(rworldmap) | |
cwur <- read.csv("cwurData.csv") | |
# data frames with the universities and count them by country |