Apply Function in R: Apply same function to for each cell of a matrix

R provides powerful functions. Apply function is one of them. It keeps you from writing boring loops(while and for). For insance:

# create a matrix of 10 rows x 2 columnsm <- matrix(c(1:10, 11:20), nrow = 10, ncol = 2)

# divide all values by apply

apply(m, 1:2, function(x) x/2)

Thanks for nsaunders


Interpreting Linear Model(lm) in R

In R as you know, when it have been written: summary(lm(x~y)), the command gives  a lot of different ‘mystic’ values. I have found a good manual for interpreting the result. It is here

Besides, do not forget lm command is relevant with “regression” model. If you want to compute the simple correlation between two parameter use cor(x,y) command.

If you do not have any idea about difference, here is good article for you