Posts Tagged ‘ data frame ’

Selection in R

June 1, 2012
By

The design of the statistical programming language R sits in a slightly uncomfortable place between the functional programming and object oriented paradigms. The upside is you get a lot of the expressive power of both programming paradigms. A downside of this is: the not always useful variability of the language’s list and object extraction operators. Related posts:

Read more »

Functions ddply and melt make plotting summary stats in R more tolerable

May 15, 2012
By
Functions ddply and melt make plotting summary stats in R more tolerable

The main reason why I have usually chosen to use excel to make my plots at work is because I had difficulty feeding the summary stats in R into a plotting function.  One thing I learned this week is how … Continue reading →

Read more »

An embarrassing admission; Copy pasting tables with text containing spaces from Excel to R

May 11, 2012
By
An embarrassing admission; Copy pasting tables with text containing spaces from Excel to R

I can’t believe I didn’t learn how to do it earlier, but I never knew how to accurately copy tables from excel that had text with spaces in them, and paste into a data frame in R without generating confusion … Continue reading →

Read more »

How to convert contingency tables to data frames with R

March 14, 2012
By

I wanted to write contingency tables in HTML with hwrite(). I realized that the method hwrite() does not exist for the table objects. I could use as.data.frame(), but the table produced is non-intuitive. I did a search on R-bloggers and I quickly found the solution to my problem: the as.data.frame.matrix() function. The contingency table A

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 »

data.frame objects in R (via “R in Action”)

December 18, 2011
By
data.frame objects in R (via “R in Action”)

The followings introductory post is intended for new users of R.  It deals with R data frames: what they are, and how to create, view, and update them. This is a guest article by Dr. Robert I. Kabacoff, the founder of (one of) the first online R tutorials websites: Quick-R.  Kabacoff has recently published the book ”R Read more...

Read more »

Identifying Records in Data Frame A That Are Not Contained In Data Frame B – A Comparison

October 12, 2011
By
Identifying Records in Data Frame A That Are Not Contained In Data Frame B – A Comparison

Yesterday I launched my first question at Stackoverflow and apparently did a lot of things wrong as I managed to get my question closed wihtin hours http://stackoverflow.com/questions/7728462/identify-records-in-data-frame-a-not-contained-in-data-frame-b I had collected 9 different solutions to the problem and made the mistake to put it all within the original question space. So people complained and told me … Continue reading...

Read more »

Programming with R – Processing Football League Data Part II

December 3, 2010
By

Following 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. To create the league table we need to count various things such as the number of games played, number

Read more »

Useful functions for data frames

August 9, 2010
By

The R software system is primarily command line based so when there are large sets of data it is not easy to browse the data frames. There are various useful functions for working with data frames. For example, after loading data from a text file we might want to view the first few lines of a

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 »