similar to: recording and taking mean of a set of matrices

Displaying 20 results from an estimated 30000 matches similar to: "recording and taking mean of a set of matrices"

2012 Oct 26
4
Merge matrices with different column names
A general question that I have been pursuing for some time but have set aside. When finishing some analysis, I can have multiple matrices that have specific column names. Ideally, I would like to combine these separate matrices for a final output as a csv file. A generic example: Matrix 1 var1A var1B var1C x x x x x
2013 Sep 05
2
binary symmetric matrix combination
Hi, May be this helps: m1<- as.matrix(read.table(text=" y1 g24 y1 0 1 g24 1 0 ",sep="",header=TRUE)) m2<-as.matrix(read.table(text="y1 c1 c2 l17 ?y1 0 1 1 1 ?c1 1 0 1 1 ?c2 1 1 0 1 ?l17 1 1 1 0",sep="",header=TRUE)) m3<- as.matrix(read.table(text="y1 h4??? s2???? s30 ?y1 0 1 1 1 ?h4 1 0 1 1 ?s2 1 1 0 1 ?s30 1 1 1
2007 Apr 27
4
Randomising matrices
I would like to be able to randomise presence-absence (i.e. binary) matrices whilst keeping both the row and column totals constant. Is there a function in R that would allow me to do this? I'm working with vegetation presence-absence matrices based on field observations. The matrices are formatted to have sites as rows and species as columns. The presence of a species on a site is
2009 May 19
4
nlrwr package. Error when fitting the optimal Box-Cox transformation with two variables
Dear all: I'm trying to fit the optimal Box-Cox transformation related to nls (see the code below) for the demand of money data in Green (3th Edition) but in the last step R gives the next error message. Error en `[.data.frame`(eval(object$data), , as.character(formula(object)[[2]])[2]) : undefined columns selected. ?Any idea to solve the problem? Thanks in advance,
2009 Jul 28
3
selecting vector elements using matrices and combining the results
I've been scratching my head over this one for too long. I'm hoping someone out there can solve this riddle. I have two vectors of characters, v1 and v2, both of length L, and two matrices of logicals, m1 and m2, both of dimension N*L. The first matrix of logicals corresponds to the first vector of characters, and the second to the second. The matrices are telling me which of the
2008 Jan 29
2
add/subtract matrices, ignoring NA or missing values
Hi, For example, given two 2x2 matrices m1 and m2. I would like to add/subtract element by element > m1 [,1] [,2] [1,] NA NA [2,] 1 2 > m2 [,1] [,2] [1,] 1 NA [2,] NA 2 > m1 + m2 [,1] [,2] [1,] NA NA [2,] NA 4 How can I ignore the NA, and get this ? Hope the solution can be extended to subtract and modulo also. [,1] [,2]
2012 Apr 10
1
compare two matrices
Dear Members, I have two estimated transition matrices and I want to compare them. In fact I want to check the hypothesis if they come from the same process. I tried to look for some test but all I found was independence test of contingency tables. The following code shows that the usual chi-squared test statistic does not follow chisq distribution. MCRepl <- 5000 khi12 <- rep(0,MCRepl)
2008 Nov 26
2
Very slow: using double apply and cor.test to compute correlation p.values for 2 matrices
My two matrices are roughly the sizes of m1 and m2. I tried using two apply and cor.test to compute the correlation p.values. More than an hour, and the codes are still running. Please help to make it more efficient. m1 <- matrix(rnorm(100000), ncol=100) m2 <- matrix(rnorm(10000000), ncol=100) cor.pvalues <- apply(m1, 1, function(x) { apply(m2, 1, function(y) { cor.test(x,y)$p.value
2012 Mar 08
4
Correlation between 2 matrices but with subset of variables
Dear All, I have two matrices A (40 x 732) and B (40 x 1230) and would like to calculate correlation between them.  I can use: cor(A,B, method="pearson") to calculate correlation between all possible pairs. But the issue is that there is one-many specific mappings between A and B and I just need to calculate correlations for those pairs (not all). Some variables in A (proteins, say p1)
2010 Apr 14
5
Running cumulative sums in matrices
Dear R-helpers, I have a huge data-set so need to avoid for loops as much as possible. Can someone think how I can compute the result in the following example (that uses a for-loop) using some version of apply instead (or any other similarly super-efficient function)? example: #Suppose a matrix: m1=cbind(1:5,1:5,1:5) #The aim is to create a new matrix with every column containing the
2008 Jun 18
1
operations on all pairs of columns from two matrices
m1 <- matrix(rnorm(40), ncol=4) m2 <- matrix(rnorm(40), ncol=4) I would like to subtract first column of m1 from all columns of m2, subtract 2nd of m1 from all columns of m2, and so on. Obviously, I am not using the appropriate function outer(m1, m1, "-"), since the first column isn't all 0s. _________________________________________________________________
2011 Jan 03
3
matrices call a function element-wise
Hello I have 4 1000*1000 matrix A,B,C,D. I want to use the corresponding element of the 4 matrices. Using the "for loop" as follow: E<-o for (i in 1:1000) {for (j in 1:1000) { E<-fisher.test(matrix(c(A[i][j],B[i][j],C[i][j],D[i][j]),2))#call fisher.test for every element } } It is so time-consuming Need vectorization Yours sincerely ZhaoXing Department of
2008 Nov 06
2
comparing matrices using max or min
Dear all, I have 3 matrices with the same dimension, A,B,C and I would like to produce a matrix D where in each position would retrieve the max(or min) value along A,B,C taken from the same position. I guess that apply functions should fit, but for matrices objects I am not getting it. thanks in advance, Diogo André Alagador [[alternative HTML version deleted]]
2012 Nov 18
1
identical matrices
Dear R users, I want to check matrices when i change the order of the rows or/and the order of the columns or/and the combination of them i will give an example what i want  1  -1  1  1      1  1   1  1 -1  -1 -1 -1    -1 -1  -1  -1   1  1    1  1     1 -1    1   1 these 2 matrices are identical because i change the first row and make it third   1  -1  1  1      -1  1   1  1 -1  -1 -1
2008 Sep 22
1
how to set rownames / colnames for matrices in a list
Hello, I have another stupid question. I hope you can give me a hint how to solve this: I have a list and one element is again a list containing matrices, all of the same dimensions. Now, I'd like to set the dimnames for all matrices: example code: m1 <- matrix(1:25, nrow=5) m2 <- matrix(26:50, nrow=5) # ... there can be much more than two matrices l <- list() l[[1]] <-
2010 Nov 17
2
slicing list with matrices
A list contains several matrices. Over all matrices (list elements) I'd like to access one matrix cell: m <- matrix(1:9, nrow=3, dimnames=list(LETTERS[1:3], letters[1:3])) l <- list(m1=m, m2=m*2, m3=m*3) l[[3]] # works l[[3]][1:2, ] # works l[[1:3]][1, 1] # does not work How can I slice all C-c combinations in the list? S?ren -- S?ren Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag,
2005 Jan 28
2
Direct sum of matrices
Hi R users: How can I built a direct sum function of matrices in R? I mean A(mxn), B(pxq), C(rxs),... X<-ds(A,B,C,...) X = [ A, 0, 0 0, B, 0 0, 0, C] ((m+p+r+...) x (n+q+s+...)) Thank you for your help. Kenneth -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
2012 May 01
2
rbind-ing numeric matrices
Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only
2008 Jul 29
1
correlation between matrices - both with some NAs
Hi everyone, I'm having trouble applying the Cor() function to two matrices, both of which contain NAs. I am doing the following: a<-cor(m1, m2, use="complete.obs") ... and I get the following error message: Error in cor(m1, m2, use = "complete.obs") : no complete element pairs Does anyone know how I can apply a correlation, ignoring any NAs? Thanks, rcoder --
2011 May 05
1
Extraction of columns from two matrices
Hi, I have two matrices with 4885 cols and 36 cols respectively . I would like to extract these 36 columns from the bigger matrix, the column values are different but the column names would be the same.Hence based on the names I would like to perform my operation. So is there any way of extracting this info in an easy way. I have tried names,which,grep,subset none have worked. Could someone help