similar to: number of zeros in a matrix -row by row

Displaying 20 results from an estimated 20000 matches similar to: "number of zeros in a matrix -row by row"

2011 Jun 02
3
Removing rows of zeros from a matrix
Hi, Can someone tell me how to remove rows of zeros from a matrix? For example if I have the following matrix, 0 0 0 1 2 8 0 0 4 56 I should end up with 0 1 2 8 4 56 -- Thanks, Jim. [[alternative HTML version deleted]]
2009 Apr 21
4
search through a matrix
Hi. I have a 925 by 925 correlation matrix corM. I want to identify all variables that have correlation greater than 0.9. Can anyone suggest an "R way" of doing this? Thank you. -- View this message in context: http://www.nabble.com/search-through-a-matrix-tp23153538p23153538.html Sent from the R help mailing list archive at Nabble.com.
2009 Sep 27
2
Count number of zeros in a collumn
I have a matrix 700x2000 which is sampled in each cycle from another matrix 788x2000 with the numbers 0,1 and 9 There is one specific collumn of this matrix, dart[,1977], that usually, after the samplimg procedure has only 1 and 9 (because the zero frequency in this collumn is low). However, when this happens, I want to include an IF conditional in my code. so basically what i wanted to do was to
2010 Mar 09
3
Removing Zeros from matrix
Hi Everybody, I have a matrix of about 45 columns. Some of the rows contain zeros. Using >data1<-data[complete.cases(data),], I can remove the "NA" rows. But I am unable to tackle that of zeros. Can anybody give me an idea of how to remove rows containing zeros in a matrix. Thanks so much Best Ogbos [[alternative HTML version deleted]]
2004 May 12
1
How to know the row number of raw matrix after r
[This email is either empty or too large to be displayed at this time]
2006 Nov 28
5
Counting zeros in a matrix
Hi All, If you could help me with this problem I would greatly appreciate it. Suppose I have a matrix A: 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 I would like, for each row, to sum the number of times a 0 appears in front of a 1. So what I would like is to have Sum 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 2 1 0 1 0 0 1 0 0 0 2 1 1 0 0 0 0 1
2009 Apr 22
2
Exporting objects plotted with plot3d() - rgl package
Dear all, Can anybody tell me how to export a 3d figure made with the plot3d function? I'm careless about whether it's still interactive or not in another format, as long I can get it out of R. Thanks! Alejandro Gonz?lez Departamento de Biodiversidad y Conservaci?n Real Jard?n Bot?nico Consejo Superior de Investigaciones Cient?ficas Claudio Moyano, 1 28014 Madrid, Spain Tel +0034
2009 Feb 24
1
replace zeros in a block diagonal matrix with small random values?
Hi All. Imagine you have a large block diagonal matrix. I'd like to replace the zeros in this matrix with small random (runif) numbers. Any ideas for a simple and efficient way to do this? Best regards, Rick DeShon
2007 May 20
2
Number of NA's in every second column
Hi R-users, How do I calculate a number of NA's in a row of every second column in my data frame? As a starting point: dfr <- data.frame(sapply(x, function(x) sample(0:x, 6, replace = TRUE))) dfr[dfr==0] <- NA So, I would like to count the number of NA in row one, two, three etc. of columns X1, X3, X5 etc. Thanks in advance Lauri [[alternative HTML version deleted]]
2008 Feb 13
2
apply on large arrays
I have a big contingency table, approximately of size 60*2*500*500, and I need to count the number of cells containing a count of 1 for each of the factors values defining the first dimension. Here is my attempt: tab1<-with(pisa1,table(CNT,GENDER,ISCOF,ISCOM)) tab2<-apply(tab1,1:4,function(x)ifelse(sum(x)==1,1,0)) tab3<-apply(tab2,1,sum) Computing tab2 is very slow. Is there a faster
2009 Jun 18
3
how to sort
Hi. I have an object. I think it is a list. > str(corTFandPCA) num [1:922, 1:5] -0.0226 -0.0504 -0.0208 -0.0582 -0.0257 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:922] "abdomen.2" "abdomimal.3" "abdominal.4" "aberration.5" ... ..$ : chr [1:5] "PC1" "PC2" "PC3" "PC4" ... I want to order it
2012 Dec 08
5
How to efficiently compare each row in a matrix with each row in another matrix?
Dear expeRts, I have two matrices A and B. They have the same number of columns but possibly different number of rows. I would like to compare each row of A with each row of B and check whether all entries in a row of A are less than or equal to all entries in a row of B. Here is a minimal working example: A <- rbind(matrix(1:4, ncol=2, byrow=TRUE), c(6, 2)) # (3, 2) matrix B <-
2007 May 25
1
Speeding up resampling of rows from a large matrix
I'm trying to: Resample with replacement pairs of distinct rows from a 120 x 65,000 matrix H of 0's and 1's. For each resampled pair sum the resulting 2 x 65,000 matrix by column: 0 1 0 1 ... + 0 0 1 1 ... _______ = 0 1 1 2 ... For each column accumulate the number of 0's, 1's and 2's over the resamples to obtain a 3 x 65,000 matrix G. For those
2011 Apr 10
3
count number of TRUEs in each row
Hi all, I have a huge matrix of TRUE/FALSE table like following, and I want to count the number of TRUEs in each row. Instead of looping through each row and do length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. [,1] [,2] [,3] [1,]TRUE FALSE FALSE [2,]FALSE TRUE TRUE Thank you in advance. Wendy -- View this message in context:
2012 Feb 20
2
Column wise matrix multiplication
Hi all, I am trying to multiply each column of a matrix such to have a unique resulting vector with length equal to the number of rows of the original matrix. In short I would like to do what prod(.) function in Matlab does, i.e. A <-matrix(c(1:10),5,2) V = A[,1]*A[,2] Thank you Graziano [[alternative HTML version deleted]]
2005 May 06
4
how to get such a subset of a matrix?
Hi everybody, Maybe this question is quite simple but i just don't know how to make it. I have a matrix a somewhat like this one but bigger: > a f g h i j k a NA NA 11 16 21 26 b NA NA 12 17 22 27 c NA 8 13 18 23 28 d NA 9 14 19 24 29 e NA 10 15 20 25 30 And i want to get the rows which at most have 2 Na. Thanks in advance. Shi Jiantao [[alternative HTML version deleted]]
2009 May 02
2
any suggestions on this error?
Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr, : invalid 'ncol' value (too large or NA) the statement was: for (i in v) {for (j in m[0,]){if(v[i]==m[0,j]){M[,-j]}}} where 'v' is a vector, and 'm' and 'M' are both matrices. -- View this message in context:
2009 Mar 14
2
permutations in R
Hi. Does anyone know of a function which will take as input a number n (or a set of n letters) and will give out, one at a time, the permutations of n (or of those n letters) as a vector? So that I can use the permutations one at a time. And such that it will exhaust all the permutations with no repeats. For example if n is 3, I would want a function which I could use in a loop and the first time
2005 Nov 22
4
the matrix of rows with specific row sums
I am just starting with R and have the following problem: given a matrix of ones and zeroes, say mdim=4 m<-matrix(round(runif(mdim^mdim)),mdim,mdim) how to construct the matrix of those rows of m, whose elements sum to 2. Contrary to the random matrix above, the actual matrix always has at least one such row. Serguei Kaniovski
2010 Mar 09
0
Removing Zeros from matrix:Problem fixed
Hey, Thanks for your great inputs. While "index = apply(mat == 0, MARGIN = 1, any)" gives you an idea of the rows containing zero(s), "index<-data[!apply(data==0,MARGIN=1,any),]" does the actual job of removing the rows with zeros. Kind regards Ogbos On 9 March 2010 15:12, Paul Hiemstra <p.hiemstra@geo.uu.nl> wrote: > Dimitris Rizopoulos wrote: > >>