# Blog Archives

## Testing function arguments in GNU R

June 28, 2013
By

Recently I have read a nice post on ensuring that proper arguments are passed to a function using GNU R class system. However, I often need a more lightweight solution to repetitive function argument testing.The alternative idea is to test function arguments against a specified pattern given in a string. The pattern I use has the form:([argument...

## Testing function agruments in GNU R

June 28, 2013
By

Recently I have read a nice post on ensuring that proper arguments are passed to a function using GNU R class system. However, I often need a more lightweight solution to repetitive function argument testing.The alternative idea is to test function arg...

## Regression regularization example

May 31, 2013
By

Recently I needed a simple example showing when application of regularization in regression is worthwhile. Here is the code I came up with (along with basic application of parallelization of code execution). Assume you have 60 observations and 50 expla...

## Model fitting exam problem

May 20, 2013
By

Recently I have run an exam where the following question had risen many problems for students (here I give its shortened formulation). You are given the data generating process y = 10x + e, where e is error term. Fit linear regression using lm, ne...

## Missing tikzDevice

April 30, 2013
By

I love using tikzDevice. When preparing LaTeX documents I switched to prepare all graphs in GNU R and then port them to TeX using tikzDevice. Recently I have moved to GNU R 3.0.0 and was shocked to find that this package is no longer available on CRAN....

## Estimating continuous piecewise linear regression

April 2, 2013
By

When talking about smoothing splines a simple point to start with is a continuous piecewise linear regression with fixed knots. I did not find any simple example showing how to estimate the it in GNU R so I have created a little snippet that does the j...

## GNU R loop speed comparison

March 16, 2013
By

Recently I had several discussions about using for loops in GNU R and how they compare to *apply family in terms of speed. I have not seen a direct benchmark comparing them so I decided to execute one (warning: some of the code presented today tak...

## Hexadecimal literals in GNU R

March 11, 2013
By

Recently I have used hexadecimal numbers in GNU R. The way they are parsed surprised me and is inconsistent with Java. As R Language Definition pdf only briefly mentions hexadecimal numbers here is what I have found.First I have checked the following c...

## Times per second benchmark

March 5, 2013
By

In GNU R the simplest way to measure execution time of a piece code is to use system.time. However, sometimes I want to find out how many times some function can be executed in one second. This is especially useful when we want to compare function...

## Solving 9-puzzle with GNU R

January 4, 2013
By

During holiday break I have decided to solve 9-puzzle, which is 3x3 variant of a well known 15-puzzle. The solution has proven to be a nice application of igraph package. Warning: this time the code takes a bit more tame than usual in my...