similar to: where two matrices differ?

Displaying 20 results from an estimated 8000 matches similar to: "where two matrices differ?"

2011 Sep 30
2
remove elements from matrix
Dear all, I have a numeric vector that contains indices. I also have two matrices of [1,m] dimension and of [m,n] dimension. I want for every indexto remove the current element from the [1,m] vector an the row from the [m,n] matrix. How I can do that efficiently in R? So to say not have a for loop getting parameter after parameter and then removing row by row from the vector and the matrix. I
2005 Oct 06
1
Compare two distance matrices
Hi all, I am trying to compare two distance matrices with R. I would like to create a XY plot of these matrices and do some linear regression on it. But, I am a bit new to R, so i have a few questions (I searched in the documentation with no success). The first problem is loading a distance matrix into R. This matrix is the output of a the Phylip program Protdist and lookes like this: 5
2010 Oct 14
1
rbind ing matrices and resetting column numbers
Sorry for the verbose example. I want to row bind two matrices, and all works except I want the column labelled "row" to be sequential in the new matrix, shown as "mat3" here, i.e. needs to be 1:6 and not 1:3 repeated twice. Any suggestions? Thanks J > colnm1 <- c("row","ti","counti") > colnm2 <-
2008 Aug 01
2
Storing Matrices into Hash
Hi, Suppose I have these two matrices (could be more). What I need to do is to store these matrices into a hash. So that I can call back any of the matrix back later. Is there a way to do it? > mat_1 [,1] [,2] [1,] 9.327924e-01 0.067207616 [2,] 9.869321e-01 0.013067929 [3,] 9.892814e-01 0.010718579 [4,] 9.931603e-01 0.006839735 [5,] 9.149056e-01 0.085094444
2009 Jul 02
2
matching rows in matrices
I have a matrix such as this, [,1] [,2] [,3] [1,] 1 1 2 [2,] 2 5 5 and a larger matrix such as this, a b [1,] 1 5 [2,] 2 5 [3,] 4 9 [4,] 5 8 [5,] 7 8 [6,] 7 10 [7,] 9 10 what I want to do is check the number of times the columns in the first matrix appear as rows in the second matrix. So for instance in this example 1,5 and 2,5 appear in both so I'd want
2008 Aug 15
2
cor() btwn columns in two matrices - no complete element pairs
Hi everyone, I'm trying to calculate correlation coefficients between corresponding columns in two matrices with identical dimensions but different data. The problem is that the matrices contain NAs in different locations. I am using the following code to try to calculate correlations between complete sets of data: #Code start maxcol<-ncol(mat1) for (i in 1:maxcol) {
2007 Aug 10
7
Help wit matrices
Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2<-as.matrix(as.numeric(mat1>0.25)) but that returns a 1:100000 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre
2010 Feb 13
3
how to do calculations in data matrices?
Please give me just a reference where I can find something useful. In summary, I need to : - find the median of each row of a matrix - create a new matrix with each value in the first matrix divided by the median of its row - if a value "a" in the second matrix is < 1, I need to substitute it with 1/a I know that for some of you it must be overeasy, but I swear I googled for two
2007 Jan 21
2
multiple bases to decimal (was: comparing two matrices)
Hi again, I was contemplating the solution using base 3: set.seed(3) mat2 <- matrix(sample(0:2, 15, replace=T), 5, 3) Extracting the line numbers is simple: bases <- c(3, 3, 3)^(2:0) # or just 3^(2:0) colSums(apply(mat2, 1, function(x) x*bases)) + 1 [1] 7 23 25 8 1 The problem is sometimes the columns have different number of levels, as in: mat1 <- expand.grid(0:2, 0:2,
2007 Nov 12
1
update matrix with subset of it where only row names match
I guess this has a simple solution: I have matrix 'mat1' which has row and column names, e.g.: A B C row1 0 0 0 row2 0 0 0 .... rown 0 0 0 I have a another matrix 'mat2', essentially a subset of 'mat1' where the rownames are all in 'mat1' e.g.: B row3 5 row8 6 row54 7 I want to insert the values of matrix mat2 for column B (in reality it could be some or
2013 Jun 24
1
help needed with printing multiple arguments as vectors, not matrices
** I am using the following way to get p-values from fiser exact test. However, I do need to print for each pair the values "n00, n01, n10, n11". How can I print that as a table and not a matrix as below along with the p-value? Any help will be greatly appreciated fish <- function(y, x) {n00 = sum((1-x)*(1-y)); n01 = sum((1-x)*y); n10 = sum(x*(1-y)); n11 = sum(x*y); a =
2013 Feb 13
3
date and matrices
Hi Elisa, Try this: date1<-format(seq.Date(as.Date("1991.1.1",format="%Y.%m.%d"),as.Date("1996.12.31",format="%Y.%m.%d"),by="day"),"%Y.%m.%d") ?length(date1) #[1] 2192 mat1<-matrix(c(.314,.314,.273,.273,.236,.236,.236,.236,.273,.314,.403,.314),ncol=1) res1<-
2010 Feb 12
3
Code working but too slow, any idea for how to speed it up ?(no loop in it)
Hello my friends, here is a code I wrote with no loops on matrix that is taking too long (2 seconds and I call him 720 times --> 12 minutes): mat1 and mat2 are both matrix with 103 columns and 164 rows. sequence <- matrix(seq(1 : ncol(mat1))) returns <- apply(sequence, 1, function, mat1= mat1, mat2 = mat2, day = 1) function<- function(mat1, mat2, colNb, day){
2005 Nov 03
4
merging dataframes
Dear List, I often have to merge two or more data frames containing unique row names but with some columns (names) common to the two data frames and some columns not common. This toy example will explain the kind of setup I am talking about: mat1 <- as.data.frame(matrix(rnorm(20), nrow = 5)) mat2 <- as.data.frame(matrix(rnorm(20), nrow = 4)) rownames(mat1) <- paste("site",
2010 Jan 29
7
Simple question on replace a matrix row
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I want to replace the first row of mat2 with mat1, this is what I do: mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand, I want it to stay a matrix... ----- Anna Lippel -- View this message in context: http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-tp1427857p1427857.html Sent from the R help
2011 May 25
1
transpose ?
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20110525/acc78a27/attachment.pl>
2011 Jun 03
1
Outputting data from TukeyHSD
Hi All, I am wondering if their is a convenient way to export the results of the TukeyHSD function to Word or Excel. I have used capture.output(tukey.contrast, file="tukey.contrast.xls") and this works, but the data are not in a table form, and so it is sort of a pain to manipulate the output. I have be unable to find a more convenient way and any assistance would be greatly
2003 Oct 31
2
Summing elements in a list
Hi, Suppose that I have a list where each component is a list of two matrices. I also have a vector of weights. How can I collapse my list of lists into a single list of two matrices where each matrix in the result is the weighted sum of the corresponding matrices. I could use a loop but this is a nested calculation so I was hoping there is a more efficient way to do this. To help clarify,
2007 Nov 21
2
matrix elementwise average with NA's
Hello fellow R users, I have a matrix computation that I imagine should be relatively easy to do, however I cannot figure out a nice way to do it. I have two matrices, for example mat1 <- matrix(c(1:5,rep(NA,5), 6:10), nrow=3, byrow=T) mat2 <- matrix(c(2:6, 6:10, rep(NA,5)), nrow=3, byrow=T) I'd like to compute the element-wise average for non-NA entries. Of course (mat1+mat2)/2
2013 Mar 18
4
Counting confidence intervals
Hi, I have a 2 x 10000 matrix of confidence intervals. The first column is the lower and the next column is the upper. I want to cont how many times a number say 12 lies in the interval. Can anyone assist? -- Thanks, Jim. [[alternative HTML version deleted]]