Archive for month: January, 2013

The three-dots construct in R

30 Jan 2013
2013/01/30

There is a mechanism that allows variability in the arguments given to R functions.  Technically it is ellipsis, but more commonly called “…”, dots, dot-dot-dot or three-dots.

Basics

The three-dots allows:

  • an arbitrary number and variety of arguments
  • passing arguments on to other functions

Arbitrary arguments

The two prime cases are the c and list functions:

> c
function (..., recursive = FALSE)  .Primitive("c")
> list
function (...)  .Primitive("list")

Both of these allow you to give them as many arguments as you like, and you can name those arguments (which end up as names in the resulting object). Read more →

A corner on convenient data analysis

24 Jan 2013
2013/01/24

Many people are of the opinion that R has a corner on convenient data analysis.  That may or may not be true.

But now R literally has a corner that makes data analysis more convenient.  If you have a data frame or a matrix with a few columns, then you can use head and/or tail to make sure that it looks as you expect.  However, the result is unappetizing if there are hundreds or thousands of columns.

That is is where corner comes in.  It shows you the first or last  few rows of the first or last few columns.

The  mtcars dataset can serve as an example even though it isn’t exactly a gigantic dataset.

By default the first 6 rows and first 6 columns are extracted:

> corner(mtcars)
                   mpg cyl disp  hp drat    wt
Mazda RX4         21.0   6  160 110 3.90 2.620
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875
Datsun 710        22.8   4  108  93 3.85 2.320
Hornet 4 Drive    21.4   6  258 110 3.08 3.215
Hornet Sportabout 18.7   8  360 175 3.15 3.440
Valiant           18.1   6  225 105 2.76 3.460

The same thing is done with: Read more →

Welcome to the Burns Statistics blog

08 Jan 2013
2013/01/08

The most likely topics to appear here are:

  • the R language
  • statistics
  • programming in general
  • optimization
© Copyright - Burns Statistics