[R] Removing NAs from matrix

2013-12-01 Thread Amie Hunter
Hello R users, I'm new to R so apologies if this question seems simple. I have a matrix which is 35000 columns by 35000 rows and I’m wanting to work out the mean of each row. I've tried using the code below on a smaller version of the matrix, but receive an error: > mat   [,1]  [,2] [,

[R] Speeding up code

2013-11-23 Thread Amie Hunter
Hello R experts, I'm new to R and I'm wanting to know what is the best way to speed up my code. I've read that you can vectorize the code but I'm unsure on how to implement this into my code. df <- data.frame(31790,31790) for (i in 1:31790) {   for (j in i:31790)   {     ken<-cor(cldm[i,3: