Blog Archives

R: Building functions – using default settings that can be modified via the dot-dot-dot / three point argument

April 7, 2009
By
R: Building functions – using default settings that can be modified via the dot-dot-dot / three point argument

Before you read this post, please have a look at Enrique’s comment below. He pointed out that the built-in R function modifyList() already does what I wanted to describe in this post. Well, I live to learn :) I was wondering how I could write a function that uses default settings but accepts a list

Read more »

How accurate or reliable are R calculations?

March 28, 2009
By
How accurate or reliable are R calculations?

On the REvolutions Blog there is a nice posting treating the often raised concern on “How good or reliable R is”. At my university R is hardly used. Sometimes I was asked by lecturers wether the calculations done by R and its packages are accurate. The linked posting treats this matter and tries to clarify

Read more »

R: Zip fastener for two data frames / combining rows or columns of two dataframes in an alternating manner

March 27, 2009
By
R: Zip fastener for two data frames / combining rows or columns of two dataframes in an alternating manner

Sometimes I find it useful to merge two data frames like the following ones   X1 X2 X3 X4 Y1 Y2 Y3 Y4 1  o  o  o  o X X X X 2  o  o  o  o X X X X 3  o  o  o  o X X X X by using zip feeding either

Read more »

R: Monitoring the function progress with a progress bar

March 16, 2009
By
R: Monitoring the function progress with a progress bar

Every once in while I have to write a function that contains a loop doing thousands or millions of calculations. To make sure that the function does not get stuck in an endless loop or just to fulfill the human need of control it is useful to monitor the progress. So  first I tried the

Read more »

R: Good practice – adding footnotes to graphics

February 17, 2009
By
R: Good practice – adding footnotes to graphics

In some statistical programs there is the option available to attach a footnote to the graphical output that is created. This footnote may contain the name of the script or the file that produced the graphic, the author’s name and the date of creation. In SAS for example there is a footnote command to achieve

Read more »

R: Calculating all possible linear regression models for a given set of predictors

February 6, 2009
By
R: Calculating all possible linear regression models for a given set of predictors

Although the graphic at the left might not seem a 100% appropriate, it gives a hint to what I am about to do. I want to calculate all possible linear regression models with one dependent and several independent variables. I do not want to address bias and fitting issues or the question if this

Read more »

R: Combining vectors or data frames of unequal length into one data frame

January 23, 2009
By
R: Combining vectors or data frames of unequal length into one data frame

Today I will treat a problem I encounter every once in a while. Let’s suppose we have several dataframes or vectors of unequel length but with partly matching column names,  just like the following ones: df1 <- data.frame(Intercept = .4, x1=.4, x2=.2, x3=.7) df2 <- data.frame(Intercept = .5,        x2=.8       ) This for example may occur when fitting several

Read more »