Blog Archives

ggPlot2: Histogram with jittered stripchart

February 5, 2014
By
ggPlot2: Histogram with jittered stripchart

Here is an example of a Histogram plot, with a stripchart (vertically jittered) along the x side of the plot.Alternatively, using the geom_rug function:Of course this simplicistic method need to be adjusted in vertical position of the stripchart or rug...

Read more »

Boxplot with mean and standard deviation in ggPlot2 (plus Jitter)

February 2, 2014
By
Boxplot with mean and standard deviation in ggPlot2 (plus Jitter)

When you create a boxplot in R, it automatically computes median, first and third quartile ("hinges") and 95% confidence interval of median ("notches").But we would like to change the default values of boxplot graphics with the mean, the mean + st...

Read more »

Implementation of the CDC Growth Charts in R

September 17, 2011
By

I implemented in R a function to re-create the CDC Growth Chart, according to the data provided by the CDC.In order to use this function, you need to download the .rar file available at this megaupload link.Mirror: mediafire link.Then unrar the file, a...

Read more »

R is a cool sound editor!

September 7, 2011
By

Capabilities of R are definitely unless! After my previous posts about some easy image editing in R (they are here, and here), now is the time to explore if R is capable of sound editing!Just for fun, here I created a function that receives a phone number (or another sequence of numbers), and returns the equivalent melody...

Read more »

R is a cool image editor #2: Dithering algorithms

August 29, 2011
By
R is a cool image editor #2: Dithering algorithms

Here I implemented in R some dithering algorithms: - Floyd-Steinberg dithering - Bill Atkinson dithering - Jarvis-Judice-Ninke dithering - Sierra 2-4a dithering - Stucki dithering - Burkes dithering - Sierra2 dithering - Sierra3 dithering For each algorithm, I wrote a 2-dimensional convolution function (a matrix passing over a matrix); it is slow because I didn't implemented any fasting tricks. It can be easily implemented in C, then used...

Read more »

Benford’s law, or the First-digit law

August 25, 2011
By
Benford’s law, or the First-digit law

Benford's law, also called the first-digit law, states that in lists of numbers from many (but not all) real-life sources of data, the leading digit is distributed in a specific, non-uniform way. According to this law, the first digit is 1 about 30% of the time, and larger digits occur as the leading digit with lower and lower frequency,...

Read more »

How to plot points, regression line and residuals

June 16, 2011
By
How to plot points, regression line and residuals

x y # plot scatterplot and the regression linemod1 plot(x, y, xlim=c(min(x)-5, max(x)+5), ylim=c(min(y)-10, max(y)+10))abline(mod1, lwd=2)# calculate residuals and predicted valuesres pre # plot distances between points and the regression linesegments(x, y, x, pre, col="red")# add labels (res values) to pointslibrary(calibrate)textxy(x, y, res, cx=0.7)

Read more »

R is a cool image editor!

November 7, 2010
By
R is a cool image editor!

Here I present some functions I wrote to recreate some of the most common image effect available in all image editor.They require the library rimage.To load the image, use:y <- read.jpeg("path") To display the image, use:plot(y)Original imageSepia tone rgb2sepia <- function(img){ iRed <- img*255 iGreen <- img*255 iBlue <- img*255  oRed <- iRed * .393...

Read more »

R is a cool image editor!

November 7, 2010
By
R is a cool image editor!

Here I present some functions I wrote to recreate some of the most common image effect available in all image editor.They require the library rimage.To load the image, use:y <- read.jpeg("path")To display the image, use:plot(y)Original imageSepia tonergb2sepia <- function(img){ iRed <- img*255 iGreen <- img*255 iBlue <- img*255  oRed <- iRed * .393...

Read more »

Fast matrix inversion

October 19, 2010
By
Fast matrix inversion

Very similar to what has been done to create a function to perform fast multiplication of large matrices using the Strassen algorithm (see previous post), now we write the functions to quickly calculate the inverse of a matrix.To avoid rewriting pages and pages of comments and formulas, as I did for matrix multiplication, this time I'll...

Read more »