Geopolitics

January 30, 2012
By
Geopolitics

The graduated symbol schematics below have been created in R (using ‘symbols’). They plot combinations of country territorial and population sizes. Instead of dividing for population density we multiply for a function of both. The total of box areas is … Continue reading →

Read more »

Printing nested tables in R – bridging between the {reshape} and {tables} packages

January 29, 2012
By
Printing nested tables in R – bridging between the {reshape} and {tables} packages

This post shows how to print a prettier nested pivot table, created using the {reshape} package (similar to what you would get with Microsoft Excel), so you could print it either in the R terminal or as a LaTeX table. This task is done by bridging between the cast_df object produced by the {reshape} package,

Read more »

Some new functions I’ve discovered in R

January 29, 2012
By
Some new functions I’ve discovered in R

I’ve been writing a fair amount of R recently and have been going through a good learning period, here are some functions that I’ve discovered (mainly plyr and reshape related) and thought I would share: merge_all is a good way to merge multiple different data frames, rather than multiple merge commands. The key thing is … Continue reading...

Read more »

Removing Multibyte Characters from Strings

January 29, 2012
By

I was a bit annoyed by the error when loading a dataset that contains multi-byte characters. R basically just chokes on them. I have not really understood the intricacies of this, but it was basically just an annoyance and since I did not really use these characters in the strings containing them, I just wanted

Read more »

hmm: implementation of viterbi algorithm (Durbin, 1998) Part 2

January 29, 2012
By
hmm: implementation of viterbi algorithm (Durbin, 1998) Part 2

Previous post presented the problem of dishonest casino that ocassionally uses loaded die. Sequence of the real states is hidden, and we are trying to figure it out just by looking at the observations (symbols). If we apply our implementation … Continue reading →

Read more »

Visual Summary of #jan25 Twitter Activity

January 29, 2012
By
Visual Summary of #jan25 Twitter Activity

  Last year, I covered a number of the so-called “Twitter protests” in China (#cn220), Iran (#25bahman), and Algeria (#fev12).  Since these protests began in January 2011, the Arab Spring has claimed many members of both ruling and revolting groups … Continue reading →

Read more »

Multiple Factor Model – Fundamental Data

January 28, 2012
By
Multiple Factor Model – Fundamental Data

The Multiple Factor Model can be used to decompose returns and calculate risk. Following are some examples of the Multiple Factor Models: The expected returns factor model: Commonality In The Determinants Of Expected Stock Returns by R. Haugen, N. Baker (1996) The expected returns factor model: CSFB Quantitative Research, Alpha Factor Framework on page 11,

Read more »

Categorizing my expenses

January 28, 2012
By
Categorizing my expenses

In order to analyse my expenses, a classification scheme is necessary. I need to identify categories that are meaningful to me. I decided to go with the “Classification of Individual Consumption by Purpose” (COICOP), for three reasons:It is made by people who have thought more about consumption classification than I ever will. It is feasible to assign bank transactions...

Read more »

Say it in R with "by", "apply" and friends

January 28, 2012
By
Say it in R with "by", "apply" and friends

Iris versicolor (Source: Wikipedia)R is a language, as Luis Apiolaza pointed out in his recent post. This is absolutely true, and learning a programming language is not much different from learning a foreign language. It takes time and a lot of pr...

Read more »

Le Monde puzzle [#755?]

January 27, 2012
By
Le Monde puzzle [#755?]

Le Monde puzzle of last weekend was about sudoku-like matrices. Consider an (n,n) matrix containing the integers from 1 to n². The matrix is “friendly” if the set of the sums of the rows is equal to the set of the sum of the columns. Find examples for n=4,5,6. Why is there no friendly matrix

Read more »

hmm: implementation of viterbi algorithm (Durbin, 1998) Part 1

January 27, 2012
By
hmm: implementation of viterbi algorithm (Durbin, 1998) Part 1

Example in the mentioned book goes as following – dishonest casino uses two types of dice. Fair one that has equal probability of landing on either side (1/6), and the loaded one with 50% chance for getting 6. Your task … Continue reading →

Read more »

heatmaps: controlling the color representation with set data range

January 27, 2012
By
heatmaps: controlling the color representation with set data range

Often you want to set the fixed colors for particular range of your dataset to be sure that the visual output is correctly represented. This is particularly useful for time series data, where the range or your dataset might drastically … Continue reading →

Read more »

Distressing Numbers for Women

January 27, 2012
By
Distressing Numbers for Women

Sometimes I play with non-linguistic data sets recreationally. It's a totally valid hobby! I tend to gravitate towards data on the disparities between men and women, because gender equality is something that matters to me.I've had this one data set for...

Read more »

Replicating NetLogo Fire model

January 27, 2012
By
Replicating NetLogo Fire model

While preparing for the new semester I have started reimplementing standard NetLogo examples in R. The first is Fire model.The simulation in R is presented here:# Forest matrix trees encoding:# 3 – green, 2 – burning, 1 – burnt, 0 – no treesimu...

Read more »

Experimenting With iGraph – and a Hint Towards Ways of Measuring Engagement?

January 27, 2012
By
Experimenting With iGraph – and a Hint Towards Ways of Measuring Engagement?

For fear of being left way behind as Martin Hawksey starts to get to grips with R, (see for example how he’s using R to automate the annotation of Google Spreadsheets with calculations that don’t come readily or efficiently to hand in Google Spreadsheets itself), I thought I better try to get to grips with

Read more »

New R User Group in Cleveland

January 27, 2012
By

Another new local R user group has just started up, this time in Cleveland, OH. The Cleveland R User Group is the brainchild of R user Nicholas Hermez, and their first meeting on February 22 is a get-together to plan future topics, presenters and venues. If you're in the Cleveland area why not drop by and contribute your ideas?...

Read more »

RStudio, BibTex, and LaTeX

January 27, 2012
By

I was having a little trouble getting RStudio to process BibTex entries and compile a LaTeX file. Bumping around on the great RStudio help forum, I found this entry, which pointed me in the direction. I needed to set a system environment variable in R ...

Read more »

Scraping Flora of North America

January 27, 2012
By

So Flora of North America is an awesome collection of taxonomic information for plants across the continent. However, the information within is not easily machine readable. So, a little web scraping is called for. rfna is an R package to collect inf...

Read more »

Parallel R Model Prediction Building and Analytics

January 26, 2012
By

Modifying R code to run in parallel can lead to huge performance gains. Although a significant amount of code can easily be run in parallel, there are some learning techniques, such as the Support Vector Machine, that cannot be easily parallelized. However, there is an often overlooked way to speed up these and other models. It...

Read more »

Text Mining and The Danish Immigration Debate

January 26, 2012
By
Text Mining and The Danish Immigration Debate

I have for a while now wanted to learn how to do text mining in R. I have played a bit around with the tm package before, but nothing really serious. Being a Danish expat that might soon move back to Denmark with a Swiss girlfriend and child, the Dani...

Read more »

Filtering a list with the Filter higher-order function

January 26, 2012
By

Last week markbulling over at Drunks & Lampposts posted a method of using sapply to filter a list by a predicate. Today the @RLangTip tip of the day was to use sapply similarly. This made makes me wonder if R‘s … Continue reading →

Read more »

Social Media Interest Maps of Newsnight and BBCQT Twitterers

January 26, 2012
By
Social Media Interest Maps of Newsnight and BBCQT Twitterers

I grabbed independent samples of 1500 recent users of the #newsnight and #bbcqt hashtags within a minute or two of each other about half an hour ago. Here’s who’s followed by 25 or more of the recent hashtaggers in each case. Can you distinguish the programmes each audience interest projection map relates to? Here’s the

Read more »

All I Don’t Know About Surveys

January 26, 2012
By
All I Don’t Know About Surveys

I believe my survey experiment Survey Time illustrated later in this post and in Google’s Visualization of Survey Responses mainly pointed out how ignorant I am about the very complicated science of surveying from building the survey to the visualiza...

Read more »

SAS Macro Simplifies SAS and R integration

January 26, 2012
By
SAS Macro Simplifies SAS and R integration

Many of us feel very enthusiastic about R. It's free, it features cutting edge applications, it has a large community of users contributing for mutual benefit, and on and on. There are also many things to like about SAS, including stability, backwards...

Read more »

Penny pinching yields pennies

January 26, 2012
By
Penny pinching yields pennies

A Greek Professor of Economics has written up a thought-provoking series of articles on complexity fetishism. As part of his …Continue reading »

Read more »

Parallel R Model Prediction Building and Analytics

January 26, 2012
By

Modifying R code to run in parallel can lead to huge performance gains. Although a significant amount of code can easily be run in parallel, there are some learning techniques, such as the Support Vector Machine, that cannot be easily parallelized. However, there is an often overlooked way to speed up these and other models. It involves executing the...

Read more »

A Short Example with R-Package osmar..

January 26, 2012
By
A Short Example with R-Package osmar..

Following up my last post in which I praised the capabilities of the osmar-package I give a short example...ps: You can also find this example at GitHub HERE.library(osmar) # this pulls the data from the OSM-Api:mydistrict <- get_osm(relation(85647)...

Read more »

Creative Commons license

January 26, 2012
By
Creative Commons license

Copyright notice: I hereby release all of the writing  content that is tagged by R, under the cc-by-sa copyrights (date: Jan 26 2012), as long as the copied content comes with proper attribution which also  includes a link to the source of the article .

Read more »

Exploring the functions in a package

January 26, 2012
By
Exploring the functions in a package

Sometimes it can be useful to list all the functions inside a package. This is done in the same way that you would list variables in your workspace. That is, using ls. The syntax is ls(pos = "package:packagename"), which is easy enough if you can remember it. Unfortunately, I never can, and have to type

Read more »