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
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", |
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
## 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) |
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
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", |
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
%!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 |
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
<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() { |
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(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) |
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(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'}", |
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
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) |
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(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) |
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
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") |
OlderNewer