R

Content about R and Splus

Poisson approximation of binomial probabilities

This is yet another experiment to see how good is the approximation of binomial probability when we use Poisson and normal distributions for scenarios with large $n$, and $p$ close to zero or one.

Consider a problem where the random variable $X$ follows a binomial distribution with a known probability of success $p$, and number of trials $n$. If $n$ becomes large, it may not be possible to calculate the probabilities by hand calculation or using a calculator.

We can approximate the binomial distribution with a normal distribution or a Poisson distribution.

Export a Table Created by R to a TeX File

Producing tables in LaTeX might be a difficult task as we can not just copy and paste a table in the editor; we have to write all the numbers and other codes. But with the help of xtable package of R it is possible to produce all the necessary codes for producing table in LaTeX and also possible to export the codes in a tex file. Suppose we have produced summary statistics for Air Pollution Data and now want to export it to a tex file as a tabular format. Here are the codes-

library(xtable)
data<-read.table("data_air.txt", header=T)
data<-data[,1:4]
s<-summary(data)

Add an animated R plot to your LaTeX document

My first introduction with LaTeX was not very pleasant. I got tired and frustrated by writing so many codes for producing a simple document; but a few days ago I could write a function for producing an animated plot in R and also could export it to my LaTeX document with all its animations intact (using animation package of R).

That really made me interested in learning LaTeX; just think a PDF book has animated plots and the readers can rewind and reverse and also can control the motion of the plots just by clicking mouse! It will be very helpful for both the writer and the readers.

Three dimensional plots using rgl package

We all know that R can do amazing things including 3 dimensional plots. scatterplot3d is probably the most popular package for doing this. But a few days ago I got introduced with rgl package which can do 3 dimensional graphs with some added advantages like we can rotate the plot using mouse, zoom in or out using the mouse scroll wheel and even can play beautiful animations.
The data I have used for all the examples here is-

Some useful bar plots using R

In this article I am trying to show how to produce bar plots using R. Many of my friends think SPSS is the most useful software for producing plots and they keep using it (some of them even use Excel!).
My goal is to show that R can do every type of graphs that other commercial softwares can do. In fact it does much better than the simple point and click packages, as R gives us much better control over our analysis.

The data of my concern is -

[code] sex income district
female 21 dhaka
male 11 dhaka
male 43 chittagong

Pages

Subscribe to RSS - R