Skip to content

Instantly share code, notes, and snippets.

Markus Gesmann mages

Block or report user

Report or block mages

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RbooksBib
bibfile <- readLines("http://www.r-project.org/doc/bib/R-books.bib")
pub.start.pos <- regexpr("publisher =", bibfile, perl=TRUE)
pub.lines <- which( pub.start.pos > 0 )
pub.split <- strsplit(bib[pub.lines], "[ =,]", perl=TRUE)
publishers <- sapply(pub.split, function(x) paste(x[-c(1:5)]))
publishers <- gsub("[{}\"),\\]", "", publishers)
publishers <- gsub("c\\(", "", publishers)
s=c("Springer", "Wiley", "Sage", "Chapman & Hall", "CRC press", "Servicio")
r=c("Springer", "Wiley", "Sage", "Chapman & Hall/CRC",
View gist:1274229
## Continue from the above R code
year.start.pos <- regexpr("year =", bibfile, perl=TRUE)
year.lines <- which( year.start.pos > 0 )
year.split <- strsplit(bib[year.lines], "[ =,]", perl=TRUE)
Pub.year <- as.numeric(sapply(year.split, "[[", 6))
tradPub <- as.data.frame(table(Pub.year))
names(tradPub) <- c("year", "traditional paper")
## Get information about the online published PDF files
library(XML)
View gist:1274265
bibfile <- readLines("http://www.r-project.org/doc/bib/R-books.bib")
pub.start.pos <- regexpr("publisher =", bibfile, perl=TRUE)
pub.lines <- which( pub.start.pos > 0 )
pub.split <- strsplit(bib[pub.lines], "[ =,]", perl=TRUE)
publishers <- sapply(pub.split, function(x) paste(x[-c(1:5)]))
publishers <- gsub("[{}\"),\\]", "", publishers)
publishers <- gsub("c\\(", "", publishers)
s=c("Springer", "Wiley", "Sage", "Chapman & Hall", "CRC press", "Servicio")
r=c("Springer", "Wiley", "Sage", "Chapman & Hall/CRC",
@mages
mages / SweaveXeLaTeXExample.Rnw
Created Oct 23, 2011
Sweave XeLaTeX Example
View SweaveXeLaTeXExample.Rnw
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
%% Copyright 2011 Markus Gesmann
\documentclass[a4paper]{article}
\usepackage[noae,nogin]{Sweave}
\usepackage{tikz}
%% attachfile2 is patched to work with xelatex
View gist:1379208
<html>
<head>
<script type="text/javascript"
src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
google.load('visualization', '1',
{'packages':['motionchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
View gist:1379449
library(XML)
participants=readHTMLTable(readLines("http://www.warwick.ac.uk/statsdept/useR-2011/participant-list.html"),
which=1, stringsAsFactors=F)
names(participants)=c("Name", "Country", "Organisation")
## Correct typo and shortcut
participants$Country <- gsub("Kngdom","Kingdom",participants$Country)
participants$Country <- gsub("USA","United States",participants$Country)
participants$Country <- factor(participants$Country)
partCountry <- as.data.frame(xtabs( ~ Country, data=participants))
library(googleVis)
View gist:1380205
library(googleVis)
df <- data.frame(country=c("US", "GB", "BR"), val1=c(10,13,14), val2=c(23,12,32))
Line <- gvisLineChart(df, xvar="country", yvar=c("val1","val2"),
options=list(
title="Hello World",
titleTextStyle="{color:'red',
fontName:'Courier',
fontSize:16}",
backgroundColor="#D3D3D3",
vAxis="{gridlineColor:'#FFFFFF'}",
View gist:1380236
G <- gvisGeoChart(Exports, "Country", "Profit", options=list(width=200, height=100))
T <- gvisTable(Exports, options=list(width=200, height=270))
M <- gvisMotionChart(Fruits, "Fruit", "Year",options=list(width=400, height=370))
GT <- gvisMerge(G,T, horizontal=FALSE)
GTM <- gvisMerge(GT, M, horizontal=TRUE, tableOptions="bgcolor= \"#CCCCCC\" cellspacing=10")
plot(GTM)
View gist:1380267
library(googleVis)
jscode <- "window.open('http://en.wikipedia.org/wiki/'
+ data.getValue(chart.getSelection()[0].row,0)); "
J1 <- gvisGeoMap(Exports, locationvar='Country', numvar='Profit',
options=list(dataMode="regions", gvis.listener.jscode=jscode))
plot(J1)
View gist:1417510
n <- 50
m <- 50
set.seed(1)
mu <- -0.4
sig <- 0.12
x <- matrix(data=rlnorm(n*m, mu, sig), nrow=m)
library(fitdistrplus)
## Fit a log-normal distribution to the 50 random data set
f <- apply(x, 2, fitdist, "lnorm")
You can’t perform that action at this time.