Using apply() on single column in matrix in R
I would like to replace a complicated for loop using apply() functions.
The first thing I would like to figure out is how to use apply() on a
matrix with 100 columns when I would only like to apply it to the first
column. Is this possible?
For example:
for (i in 1:100){ if (runif(1,0,1)<0.01) { a[i,1]<-3-b[i,1] } }
How can I translate this to apply?
No comments:
Post a Comment