search for: diagonal

Displaying 20 results from an estimated 733 matches for "diagonal".

2007 Oct 10
3
as.dist with diagonal unequal zero
Hello and sorry that I still haven?t found a solution for my problem. I need to extract the lower and upper triangle from a square matrix including the diagonal. This diagonal is not zero in that special case. I tried with as.dist w<-as.dist(w, diag = TRUE) > w 1 2 3 4 5 1 0 2 2 0 3 3 8 0 4 4 9 14 0 5 5 10 15 20 0 but found no way to keep the diagonal that is in the matrix. I also tried this but as I expected it makes no differ...
2011 Jul 19
2
Taking all "complete" diagonals of a matrix
Hi R-Help! I am trying to find a nicer way of extracting all the "complete" diagonals of a matrix. I am working with very large matrices that have many more rows than columns. I want to be able to extract each of the diagonals that are as long as the number of columns in the matrix. I have written a rather ugly function that presently does the job. It illustrates what I am tryi...
2013 Jan 23
2
setting off-diagonals to zero
...:(i + 5) SEQ <- SEQ[SEQ > 0 & SEQ < 366] MAT[(1:365)[-SEQ], i] <- 0 } #works great for (i in 1:365) { SEQ <- (i - 5):(i + 5) SEQ <- SEQ[SEQ > 0 & SEQ < 366] MAT[(1:365)[-SEQ], i + 365] <- 0 } #zero's out everything, including main-diagonal and near-main-diagonal terms??? for (i in 731:1095) { SEQ <- (i - 5):(i + 5) SEQ <- SEQ[SEQ > 730 & SEQ < 1096] MAT[(731:1095)[-SEQ], i + 365] <- 0 } View(MAT) I'm not sure why the third FOR loop above is not leaving the main-diagonal and near-main-diagonal...
2007 Jun 20
1
How to extract diagonals
Hello, I am using Mac OS X on a power book and R 2.5.0 I try to extract a diagonal from a dissimilarity matrix made with dsvdis, with this code: diag(DiTestRR) But I get this error message: Fehler in array(0, c(n, p)) : 'dim' spezifiziert ein zu großes Array english: Error in array(0, c(n, p)) : 'dim' specifies a too big array. Is there a limit to extract...
2007 Aug 30
2
Need help putting histograms on the diagonal of a splom plot
Hello, I am in need of help in putting histograms on the diagonal of a plot produced with splom(). The plot matrix I am trying to produce is to have standard scatterplots in the upper-left triangle, contour plots in the lower-right triangle, and histograms on the diagonal. I have a function that does the first two, but the histograms on the diagonal has been...
2004 Oct 13
2
diagonal matrix construction
Hi, I have worked long and hard and looked in the manuals and am having a hard time constructing a diagonal matrix. I can get the diagonals out of a matrix but can't construct the matrix with just the diagonals. I have been on the web site and manuals and I think that it says to use: dsj <- diag (three = 1, nrow, ncol = 7) three is the name of my matrix and dsj is whe...
2009 Dec 15
2
Diagonal Labels on "Beside" Bars in Barplot
...> 6th January 2007 URL: http://zoonek2.free.fr/UNIX/48_R/all.html data(HairEyeColor) a <- as.table( apply(HairEyeColor, c(1,2), sum) ) # Provided Example barplot(a, beside = TRUE, legend.text = attr(a, "dimnames")$Hair) # I would like to make the labels on the x-axis diagonal, so I tried the following: barplot_reference<-barplot(a, beside = TRUE, legend.text = attr(a, "dimnames")$Hair, xaxt = "n", xlab = "") text(barplot_reference, par("usr")[3] - 0.09, srt = 45, adj = 1,...
2013 Apr 19
3
extracting the diagonal of an inverse matrix
Dear R-users, I would like to know whether there is a way to extract a diagonal of an inverse matrix without computing the inverse of the matrix itself. The size of my matrices are really huge and, also using sparse matrix, computing the inverse leads to storage problems and low speed. In other words, given a square matrix A, I aim to know diag(B), where B=solve(A), without c...
2008 Feb 26
2
Summing up diagonals w/o for-loop
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile Url: https://stat.ethz.ch/pipermail/r-help/attachments/20080226/43b3a38b/attachment.pl
2008 Nov 21
2
Extracting diagonal matrix
Dear All, I have a correlation matrix of size 100 x 100 and would like to extract the diagonal matrix from it. I have used the for loop to store tha correlation values of the diagonal matrix. Is there a 'R way' of doing this? Thanks in advance. Kind regards, Ezhil
2006 Oct 03
4
how ot replace the diagonal of a matrix
Dear useRs, Trying to replace the diagonal of a matrix is not working for me. I want a matrix with .6 on the diag and .4 elsewhere. The following code looks like it should work--when I lookk at mps and idx they look how I want them too--but it only replaces the first element, not each element on the diagonal. mps <- matrix(rep(.4, 3*3...
2011 Apr 04
1
Ordering every row of a matrix while ignoring off diagonal elements
Sorry if this is a stupid question but I've been stuck on how to code so that I can order rows of a matrix without paying attention to the diagonal elements. Say, for example, I have a matrix d: > d [,1] [,2] [,3] [,4] [1,] 0.000000 2.384158 2.0065682 2.2998856 [2,] 2.384158 0.000000 1.4599928 2.4333213 [3,] 2.006568 1.459993 0.0000000 0.9733285 [4,] 2.299886 0.000000 0.9733285 0.0000000 Then I'd like ordered d...
2015 Oct 29
2
Extraer elementos diagonales de submatrices
...1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5), .Dim = c(10L, 5L)) m ## output output <- c(1:3, 1:5, 1:2) output nfilas <- nrow(m) while(nfilas > 0) { diagonal <- diag(m) elementosDeseadosDiagonal <- diagonal[diagonal>0] GuardoElementosDeseadosDiagonal <- rbind(elementosDeseadosDiagonal) PuntoDeCorte <- length(elementosDeseadosDiagonal) print(paste("Corte ", PuntoDeCorte,sep="")) while(PuntoDeCorte > 0) {...
2003 Oct 01
4
Solving a tridiagonal system
I need to find solutions to a tridiagonal system. By this I mean a set of linear equations Ax = d where A is a square matrix containing elements A[i,i-1], A[i,i] and A[i,i+1] for i in 1:nrow, and zero elsewhere. R is probably not the ideal way to do this, but this is part of a larger problem that requires R. In my application it is much e...
2010 Oct 11
1
running R script on linux server
.../init/bash module load R/2.11.1 /home/uqlcatta/script/diag.sh The .pbs file calls a .sh file, which is located on my home directory on the cluster, and which contains the R script (enclosed in " ") to run #!/bin/bash echo " mat <- matrix(1:12,nrow=3,ncol=4) diagonal <- diag(mat) write.csv(diagonal, file = "diagonal.csv") " > R_tmp echo 'source("R_tmp")' | R --vanilla --slave rm R_tmp However the cluster sends back to me an error message saying: Error in write.table(diagonal, file = diagonal.csv, col...
2011 Jan 20
2
splitting a square symmetric matrix
So many matrices are square symmetrical (i.e. variance-covariance matrices), is there any way to get R to split the matrix on its diagonal and just return one diagonal? So if I have mat<-matrix(c(1,4,3,4,1,2,3,2,1), nrow = 3, ncol=3, byrow=TRUE) is there anyway to get the lower right diagonal instead of the entire symmetric matrix? ------------------------------------------- Joe King, M.A. Ph.D. Student Universi...
2009 Aug 24
1
Filling matrix secondary diagonal
Hi, how do i fill the secondary diagonals of a matrix? Is there an funktion like the "diag" funktion in matlab, where i can specify the diagonal i?d like to fill? -- View this message in context: http://www.nabble.com/Filling-matrix-secondary-diagonal-tp25121745p25121745.html Sent from the R help mailing list archive at Nabbl...
2008 Apr 08
2
diagonally fill a rectangle with color gradient
Hi, Is it possible to diagonally fill a rectangle with a color gradient? I noticed that the gradient.rect of plotrix could fill a rect either up and down or from side to side. I am looking for something similar but fills diagonally instead, e.g., from the upper left corner to the bottom right. Does anyone know how to do it in R?...
2010 Apr 23
3
reordering of matrix rows to maximize the sum of the diagonal
Hi r-help community, This question isn't so much a syntax/coding one, but here goes: Let's say I have matrix of arbitrary dimensions and I'd like to reorder the rows in such a way that I could maximize the sum of the entries along the diagonal. For example, for this 3x3 matrix: [,1] [,2] [,3] [1,] 3 4 13 [2,] 9 1 2 [3,] 2 11 1 rearranging the rows to maximize the sum along the diagonal would produce this matrix: [,1] [,2] [,3] [1,] 9 1 2 [2,] 2 11 1 [3,] 3 4 13 I've b...
2015 Oct 28
3
Extraer elementos diagonales de submatrices
...la lista de números le es útil? > > > > Javier Rubén Marcuzzi > Técnico en Industrias Lácteas > Veterinario > > > > > > > *De: *Jorge I Velez > *Enviado: *miércoles, 28 de octubre de 2015 12:15 > *Para: *R-help-es > *Asunto: *[R-es] Extraer elementos diagonales de submatrices > > > > > > Buenos dias a todos, > > > > Quisiera extraer algunas entradas de una matrix "m" teniendo en cuenta > algunas restricciones. El siguiente ejemplo ilustra la situacion: > > > > ## input > > m <- structure(c...