Blog Archives

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 »

R-Function to Read Data from Google Docs Spreadsheets

March 13, 2012
By
R-Function to Read Data from Google Docs Spreadsheets

I used this idea posted on Stack Overflow to plug together a function for reading data from Google Docs spreadsheets into R. google_ss <- function(gid = NA, key = NA) { if (is.na(gid)) {stop("\nWorksheetnumber (gid) is missing\n")} if (is....

Read more »

Apprentice Piece with Lattice Graphs

February 28, 2012
By
Apprentice Piece with Lattice Graphs

Lattice graphs can be quite tedious. I don't use them too often and  when I need them I usually have to dig the archives for the parameter-details.The here presented example may serve as a welcome template for the usage of panel functions, panel o...

Read more »