This post will consider some useful functions for dealing with data frames during data processing and validation. Read the rest of this entry »
Getting rid of white space at the beginning and end of a string
July 28th, 2011There are situations where we are working with character strings extracted from various sources and it can be annoying when there is white space at the beginning and/or end of the strings. This whitespace can cause problems when attemping to sort, subset or various other common operations. Read the rest of this entry »
Handling Errors Gracefully
May 27th, 2011In R functions sometimes produces warnings or errors. In the case of errors execution of a function or a series of commands can get halted when an error occurs, which can in some cases be frustrating especially if we want to continue our calculations. Read the rest of this entry »
R Matrix Operations
March 27th, 2011R can be used to perform various matrix calculations. This include functions for creating matrices (matrix), addition (+), multiplication (%*%) and inversion (solve). Read the rest of this entry »
Programming with R – Processing Football League Data Part II
December 3rd, 2010Following on from the previous post about creating a football result processing function for data from the football-data.co.uk website we will add code to the function to generate a league table based on the results to date. Read the rest of this entry »
Programming with R – Checking Data Types
November 13th, 2010There are a number of useful functions in R that test the variable type or convert between different variable types. These can be used to validate function input to ensure that sensible answers are returned from a function or to ensure that the function doesn’t fail. Read the rest of this entry »
Programming with R – Checking Function Arguments
October 25th, 2010In a previous post we considered writing a simple function to calculate the volume of a cylinder by specifying the height and radius of the cylinder. The function did not have any checking of the validity of the function arguments which we will consider in this post. Read the rest of this entry »
Programming with R – Function Basics
October 20th, 2010One of the benefits of using R for statistical analysis is the programming language which allows users to define their own functions, which is particularly useful for analysis that needs to be repeated. For example, a monthly output from a database may be provided in a pre-determined format and we might be interested in running the same initial analysis on the data. Read the rest of this entry »