Blog Archives

Reproducible Research: Running odfWeave with 7-zip

April 25, 2012
By

odfWeave is an R-package that is used for making dynamic reports by Sweave processing of Open Document Format (ODF) files. For anyone new to report generation and lacking knowledge of markup languages this might be a good starting point or even a true ...

Read more »

Reproducible Research: Export Regression Table to MS Word

April 20, 2012
By
Reproducible Research: Export Regression Table to MS Word

Here's a quick tip for anyone wishing to export results, say a regression table, from R to MS Word:require(R2wd)# install packages required# install software RCOM, RDCOMClient # (I had to restart the R-Session after the above step to get it work)wdGet(...

Read more »

R-Bloggers’ Web-Presence

April 6, 2012
By

We love them, we hate them: RANKINGS!Rankings are an inevitable tool to keep the human rat race going. In this regard I'll pick up my last two posts (HERE & HERE) and have some fun with it by using it to analyse R-Bloggers' web presence. I will use...

Read more »

A Little Web Scraping Exercise with XML-Package

April 5, 2012
By

Some months ago I posted an example of how to get the links of the contributing blogs on the R-Blogger site. I used readLines() and did some string processing using regular expressions.With package XML this can be drastically shortened - see this:# get...

Read more »

Playing with XML-Package: Get No. of Google Search Hits with R

March 30, 2012
By
Playing with XML-Package: Get No. of Google Search Hits with R

GoogleHits <- function(input) { require(XML) require(stringr) require(RCurl) url

Read more »

Applying Same Changes to Multiple Dataframes

March 28, 2012
By
Applying Same Changes  to Multiple Dataframes

How to apply the same changes to several dataframes andsave them to CSV: # a dataframea <- data.frame(x = 1:3, y = 4:6)# make a list of several dataframes, then apply function (change column names, e.g.):my.list <- list(a, a)my.list <- lapply(...

Read more »

How to Extract Citation from a Body of Text

March 26, 2012
By
How to Extract Citation from a Body of Text

Say, you have a text and you want to retrieve the cited names and years of publication. You wouldn't want to this by hand, wouldn't you?Try the following approach:(the text sample comes from THIS freely available publication)library(stringr)(txt <- ...

Read more »

Classification Trees and Spatial Autocorrelation

March 25, 2012
By
Classification Trees and Spatial Autocorrelation

I'm currently trying to model species presence / absence data (N = 523) that were collected over a geographic area and are possibly spatially autocorrelated. Samples come from preferential sites (sea level > 1200 m, obligatory presence of permanent ...

Read more »

Custom Summary Stats as Dataframe or List

March 24, 2012
By
Custom Summary Stats as Dataframe or List

On Stackoverflow I found this useful example on how to apply custom statistics on a dataframe and return the results as list or dataframe:somedata<- data.frame(               ...

Read more »

Creating a Stratified Random Sample of a Dataframe

March 14, 2012
By
Creating a Stratified Random Sample of a Dataframe

Expanding on a question on Stack Overflow I'll show how to make a stratified random sample of a certain size: d <- expand.grid(id = 1:35000, stratum = letters)p = 0.1dsample <- data.frame()system.time(for(i in levels(d$stratum)) { dsub <...

Read more »