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


T-Test in Statistics

A bottle filling machine is set to fill bottles with soft drink to a volume of 500 ml. The actual volume is known to follow a normal distribution. The manufacturer believes the machine is under-filling bottles. A sample of 20 bottles is taken and the volume of liquid inside is measured.

Good and sweat guide here'da ücretsiz bir web sitesi ya da blog oluşturun.

Yukarı ↑