Anish Sing Walia explains the basics of random forests and provides sample code in R:
Random Forests are similar to a famous Ensemble technique called Bagging but have a different tweak in it. In Random Forests the idea is to decorrelate the several trees which are generated on the different bootstrapped samples from training Data.And then we simply reduce the Variance in the Trees by averaging them.
Averaging the Trees helps us to reduce the variance and also improve the Perfomance of Decision Trees on Test Set and eventually avoid Overfitting.The idea is to build lots of Trees in such a way to make the Correlation between the Trees smaller.
Random forests frequently give a good answer to classification problems, enough so as to make them a nice starting point.