On Dec 4, 2009, at 1:27 PM, Gray Calhoun wrote:
Hi Muhammad,
Load the data from all of the files into an array (probably using a
for loop), then call apply on the resulting array: ie
I like that idea a lot and it does not need an explicit loop:
apply( array(c(File1, File2, File3), dim=c(3,3
Hi Muhammad,
Load the data from all of the files into an array (probably using a
for loop), then call apply on the resulting array: ie
## replace the first line with code to load your data
> rr <- array(c(rep(1:3,3), rep(4:6,3), rep(7:9,3)), c(3,3,3))
> apply(rr, c(1,2), sd)
[,1] [,2] [,3]
Muhammad -
Here's one way:
files = c('File1','File2','File3')
themats = lapply(files,read.table)
ans = matrix(0,3,3)
for(i in 1:3)for(j in 1:3)ans[i,j] = sd(sapply(themats,function(x)x[i,j]))
Here's another
files = c('File1','File2','File3')
themats = lapply(files,read.table)
ans =
outer
Hello R-users,
I would like to know how to find the standard deviation for each element
in a set of matrices.
Given the following files,
File1File2File3
1 1 1 4 4 4 7 7 7
2 2 2 5 5 5 8 8 8
3 3 3 6 6 6 9 9 9
I want to calculate the standard deviation for every
4 matches
Mail list logo