Blog Archives

Google Maps and ggmap

December 22, 2013
By
Google Maps and ggmap

The ggmap package can be used to access maps from the Google Maps API and there are a number of examples on various statistics related blogs. These include here, here and here. The ggmap package has a function get_map that can download maps from various sources including Google Maps. require(ggmap) The first example specifies the

Read more »

Word Clouds using Text Mining

December 19, 2013
By
Word Clouds using Text Mining

There was an interesting post on a blog which showed how straightforward it is to use the text mining tools (tm) from R along with the wordcloud package to create Word Clouds. Following the example from this page I processed the text of the Golden Asse book (found at Project Guttenberg) to generate a word

Read more »

Seasonal Trend Decomposition in R

January 11, 2013
By
Seasonal Trend Decomposition in R

The Seasonal Trend Decomposition using Loess (STL) is an algorithm that was developed to help to divide up a time series into three components namely: the trend, seasonality and remainder. The methodology was presented by Robert Cleveland, William Cleveland, Jean McRae and Irma Terpenning in the Journal of Official Statistics in 1990. The STL is

Read more »

Split strings based on a character in the string

December 11, 2012
By

R has various facilities for string manipulation including the strsplit function to divide a string into substrings based on matching to another string. A simple example is shown below > strsplit("<td class=\"objectName\"><a href=\"/path/test.html\" target=\"\" title=\"An Object\" class=\"myObject\">Stuff</a></td>", "<") ] "" "td class=\"objectName\">" "a href=\"/path/test.html\" target=\"\" title=\"An Object\" class=\"myObject\">Stuff" "/a>" "/td>"

Read more »

Theme Elements in ggplot2

May 3, 2012
By

This website provides a simple summary of the theme elements that can be set within ggplot2. There should be sufficient information here to change the default settings for graphs within the ggplot2 package.

Read more »

Melt

April 5, 2012
By

There are many situations where data is presented in a format that is not ready to dive straight to exploratory data analysis or to use a desired statistical method. The reshape2 package for R provides useful functionality to avoid having to hack data around in a spreadsheet prior to import into R. The melt function

Read more »

Useful functions for data frames in R

February 17, 2012
By

This post will consider some useful functions for dealing with data frames during data processing and validation. Consider an artifical data set create using the expand.grid function where there are duplicate rows in the data frame. > des = expand.grid(A = c(2,2,3,4), B = c(1,3,5,5,7)) > des A B 1 2 1 2 2 1

Read more »

Surfaces in ternary plots

January 31, 2012
By
Surfaces in ternary plots

In mixture experiments there is a constraint that the variables are the proportions of components that are mixed together with the consequence that these proportions sum to one. When fitting regression models to data from mixture experiments we may be interested in reprenting the fitted model with a surface plot. The constraint on proportions means

Read more »

Tikz absolute positioning

November 20, 2011
By

When working with a tikz drawing within LaTeX document we might want to locate an object using an absoute position on the page rather than leaving LaTeX to make the decision for us. The use of nodes and the current.page label in conjunction with some other parameters attached to the tikz drawing will allow us

Read more »

Tikz Nodes

October 17, 2011
By
Tikz Nodes

Nodes are used in tikz to place content in a picture as part of a LaTeX document. Fast Tube by Casper When creating a tikz picture the origin is assumed to be at (0,0) and objects are placed with positioning relative to the origin on the picture. If we wanted to add a grid with

Read more »