# R code

### Le Monde puzzle [#8]

March 29, 2011 |

Another mathematical puzzle from Le Monde that relates to a broken calculator (skipping the useless tale): Given a pair of arbitrary positive integers (x,y) a calculator can either substract the same integer [lesser than min(x,y)] from both x and y or multiply either x or y by 2. ... [Read more...]

### Plotting Indifference Curves with R Contour Function

March 11, 2011 |

The following post at Constructing Difference Curves - Part 3 from economics.about.com provides a discussion on indifference curves (but actually I think they are isoquants) and how to construct them. I think I have a grasp on how to do this in R if yo...

### Copula Functions, R, and the Financial Crisis

March 10, 2011 |

From: In defense of the Gaussian copula, The Economist"The Gaussian copula provided a convenient way to describe a relationship that held under particular conditions. But it was fed data that reflected a period when housing prices were not correlated to the extent that they turned out to be when ...

### Merging Multiple Data Frames in R

January 23, 2011 |

Earlier I had a problem that required merging 3 years of trade data, with about 12 csv files per year. Merging all of these data sets with pairwise left joins using the R merge statement worked (especially after correcting some errors pointed out by Ha...

### Flexibility of R Graphics

January 21, 2011 |

(note scroll all the way down to see 'old code' and 'new more flexible code' Recall and older post that presented overlapping density plots using R (Visualizing Agricultural Subsidies by KY County) see image below.The code I used to produce this plot m...

### Posted Question for R Users

January 21, 2011 |

I recently undertook a project where a colleague had about 12 .csv files that they wanted to merge. Each file had a common (key) variable 'Partner' (which is trading partner) with differing columns (variables) except for the common key variable. Actual...

### R Code Documentation Template

January 15, 2011 |

# *------------------------------------------------------------------# | PROGRAM NAME: # | DATE: # | CREATED BY: # | PROJECT FILE: # *----------------------------------------------------------------# | PURPOSE: # |# *-------...

### R Code for googleVis Demo

January 12, 2011 |

# ------------------------------------------------------------------# | PROGRAM NAME: googleVis_R# | DATE: 1/12/11 # | CREATED BY: Matt Bogard# | PROJECT FILE: # |----------------------------------------------------------------# | PURPOSE: ...

### Visualizing Agricultural Subsidies by Kentucky County

December 12, 2010 |

In this post,  I provide results from my first full blown application of R to read, merge, clean, subset, manipulate, analyze and visualize data related to agricultural subsidies by Kentucky counties. This is very similar to the work I do on a daily basis, and was a great test of ...

### R Code Example for Neural Networks

December 12, 2010 |

See also NEURAL NETWORKS. In this past June's issue of R journal, the 'neuralnet' package was introduced. I had recently been familiar with utilizing neural networks via the 'nnet' package (see my post on Data Mining in A Nutshell) but I find the neuralnet package more useful because it will ...

### Le Monde puzzle [34]

October 3, 2010 |

Since the puzzle in this week (-end) edition of Le Monde is not (easily) solvable via an R program, I chose to go back to an older puzzle that my students can solve. Eleven [distinguishable] token are [arbitrarily] distributed around a 200 meter perimeter-long ring. They all start moving at the ... [Read more...]

### Data Mining in A Nutshell

September 20, 2010 |

# The following code may look rough, but simply paste into R or# a text editor (especially Notepad++) and it will look# much better.# PROGRAM NAME: MACHINE_LEARNING_R# DATE: 4/19/2010# AUTHOR : MATT BOGARD# PURPOSE: BASIC EXAMPLES OF MACHINE LEAR...

### R Code Examples

September 19, 2010 |

Data Mining in a Nutshell 'neuralnet'  neural network estimation and visualizationVisualizing Agricultural Subsidies by KY County R Code For googleVis  Data Visualization

### Taking R to the Limit: Large Datasets; Predictive modeling with PMML and ADAPA

August 30, 2010 |

During the first part of our meeting, Ryan Rosario presented on the topic of large datasets in R. Video, slides and code of the talk “Taking R to the Limit: Large Datasets” by Ryan Rosario at the Los Angeles area … Continue reading →

### Taking R to the Limit: Parallelization

July 29, 2010 |

Video, slides and code of the talk “Taking R to the Limit: Parallelization” by Ryan Rosario at the Los Angeles area R Users Group in July 2010 as follows. Slides: R code: here. Video: If you have a question to … Continue reading →

### Clustergram: visualization and diagnostics for cluster analysis (R code)

June 15, 2010 |

About Clustergrams In 2002, Matthias Schonlau published in “The Stata Journal” an article named “The Clustergram: A graph for visualizing hierarchical and . As explained in the abstract: In hierarchical cluster analysis dendrogram graphs are used to visualize how clusters are formed. I propose an alternative graph named “clustergram” to examine how ... [Read more...]

### How to upgrade R on windows – another strategy (and the R code to do it)

April 23, 2010 |

Update: In the end of the post I added simple step by step instruction on how to move to the new system. I STRONGLY suggest using the code only after you read the entire post. Background If you didn’t hear it by now – R 2.11.0 is out with a bunch ... [Read more...]

### formatR: farewell to ugly R code

April 13, 2010 |

It is not uncommon to see messy R code which is almost not human-readable like this: # rotation of the word "Animation" # in a loop; change the angle and color # step by step for (i in 1:360) { # redraw the plot again and again plot(1,ann=FALSE,type="n",axes=FALSE) # rotate; use ... [Read more...]

### Correlation scatter-plot matrix for ordered-categorical data

April 7, 2010 |

When analyzing a questionnaire, one often wants to view the correlation between two or more Likert questionnaire item’s (for example: two ordered categorical vectors ranging from 1 to 5). When dealing with several such Likert variable’s, a clear presentation of all the pairwise relation’s between our variable can be ... [Read more...]

### Quantile LOESS – Combining a moving quantile window with LOESS (R function)

April 1, 2010 |

In this post I will provide R code that implement’s the combination of repeated running quantile with the LOESS smoother to create a type of “quantile LOESS” (e.g: “Local Quantile Regression”). This method is useful when the need arise to fit robust and resistant (Need to be verified) ... [Read more...]
1 2 3