Articles by Todos Logos

ggPlot2: Histogram with jittered stripchart

February 5, 2014 | Todos Logos

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...]

Implementation of the CDC Growth Charts in R

September 17, 2011 | Todos Logos

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 | Todos Logos

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 ... [Read more...]

R is a cool image editor #2: Dithering algorithms

August 29, 2011 | Todos Logos

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); ... [Read more...]

Benford’s law, or the First-digit law

August 25, 2011 | Todos Logos

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 ... [Read more...]

How to plot points, regression line and residuals

June 16, 2011 | Todos Logos

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 (... [Read more...]

Fast matrix inversion

October 19, 2010 | Todos Logos

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 ... [Read more...]

Convert decimal to IEEE-754 in R

October 6, 2010 | Todos Logos

For some theory on the standard IEEE-754, you can read the Wikipedia page. Here I will post only the code of the function to make the conversion in R.First we write some functions to convert decimal numbers to binary numbers:decInt_to_8bit q r xx for(i in 1:... [Read more...]

Bhapkar V test

April 28, 2010 | Todos Logos

This is the code to perform the Bhapkar V test. I've rapidly wrote it, in 2 hours. The code is then quite brutal and it could be done better. As soon as possible, I will correct it.WARNING: it works *ONLY* with 3 groups, for now!bhapkar.test.3g sample for(i ... [Read more...]

Latin squares design in R

January 6, 2010 | Todos Logos

The Latin square design is used where the researcher desires to control the variation in an experiment that is related to rows and columns in the field.Remember that: * Treatments are assigned at random within rows and columns, with each treatment once per row and once per column. * There are ... [Read more...]

Polynomial regression techniques

September 5, 2009 | Todos Logos

Suppose we want to create a polynomial that can approximate better the following dataset on the population of a certain Italian city over 10 years. The table summarizes the data:$$\begin{tabular}{|1|1|}\hline Year & Population\\ \hline 1959&4835\\ 1960&4970\\ 1961&5085\\ 1962&5160\\ 1963&5310\\ 1964&5260\\ 1965&5235\\ 1966&5255\\ 1967&5235\\ 1968&5210\\ 1969&5175\\ \hline \end{tabular}$$First we import the data into R:Year Population Now we create ... [Read more...]

Simple logistic regression on qualitative dichotomic variables

August 20, 2009 | Todos Logos

In this post we will see briefly how to implement a logistic regression model if you have categorical variables, or qualitative, organized in double entry contingency tables. In this model the dependent variable (Y) and independent variable (X) are both dichotomies (or Bernoullian).In general, the probability that Y = 1 as ... [Read more...]

Trend Analysis with the Cox-Stuart test in R

August 8, 2009 | Todos Logos

The Cox-Stuart test is defined as a little powerful test (power equal to 0.78), but very robust for the trend analysis. It is therefore applicable to a wide variety of situations, to get an idea of the evolution of values obtained. The proposed method is based on the binomial distribution. In ... [Read more...]

Two-way analysis of variance: two-way ANOVA in R

August 7, 2009 | Todos Logos

The one-way analysis of variance is a useful technique to verify if the means of more groups are equals. But this analysis may not be very useful for more complex problems. For example, it may be necessary to take into account two factors of variability to determine if the averages ... [Read more...]
1 2

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)