similar to: Eliminating columns that sum to zero

Displaying 20 results from an estimated 20000 matches similar to: "Eliminating columns that sum to zero"

2009 May 29
2
excluding NAs in data frame without deleting rows
Hi all, I have a binary matrix with NAs included. Each row and column includes at least one NA, so I don't want to omit them. Is there a way to sum across rows and columns, ignoring the NAs but not deleting the row or column? If not, I suppose I can write a loop function, but I have learned that it is best to stay away from loops if possible. Thanks for any help, Wade
2006 Jun 21
3
sort matrix by sum of columns
Hi all, I would like to know how can I sort the cols of a matrix by the sum of their elements. a <- matrix(as.integer(rnorm(25,4,2)),10,5) colnames(a) = c("alfa","bravo","charlie","delta","echo") I guess I should use colSums, and then rearrange the matrix somehow according to the result. My idea is to display a "sorted" barplot:
2008 Oct 14
4
request: How to ignore columns having zero sums
Dear friends I have an array consist of r-rows and c-columns e.g. x=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,0,0,0,0,0,0,0,0); x1=array(x, dim=c(4,6)) output is > x1 [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 2 3 4 0 0 [2,] 1 2 3 4 0 0 [3,] 1 2 3 4 0 0 [4,] 1 2 3 4 0 0 How can i ignore columns having zero sums? Help in this regard
2010 Oct 27
1
return NA instead zero when summing over an empty range?
Dear R users, the colSums function from the base package returns zero if there are no values in a range to be summed over (after removing missing values with na.rm = TRUE). Is there some way to make it return NA in that case just like colMeans does? Or any other function or some good way to achieve that? Any ideas are be welcome. Regards, Martin Ivanov
2005 Aug 05
6
Computing sums of the columns of an array
Hi, I have a 5x731 array A, and I want to compute the sums of the columns. Currently I do: apply(A, 2, sum) But it turns out, this is slow: 70% of my CPU time is spent here, even though there are many complicated steps in my computation. Is there a faster way? Thanks, Martin
2009 Jan 20
2
Summing Select Columns of a Data Frame?
Hi, I would like to operate on certain columns in a dataframe, but not others. My data looks like this: x1 x2 x3 1 2 3 4 5 6 7 8 9 I want to create a new column named x4 that is the sum of x1 and x2, but NOT x3. I looked at colSums and apply, but those functions seem to use all the columns in a dataframe. How do I only use select columns? If it helps, in Stata this would be gen x4
2015 Feb 23
3
[LLVMdev] Eliminating redundant loads
On 23 February 2015 at 01:29, Kamal Sharma <kgs1.rice at gmail.com> wrote: > Hi Dibyendu, > > It would be very helpful if you could post the original source code or > snippet. > That way, one can investigate deeper to understand the problem. > > Regards, > Kamal Sharma > Hi Kamal, Sure. I guess I ought to create a test that one can look in isolation. I am
2007 Apr 25
1
Sum of specific column
I have a data set that I have imported (not sure if that makes a difference) and I would like to calculate the sum of only specific columns. I have tried >colSums(dataset, by=list(dataset$col5), dims=1) and I get an error of unused arguments I have also tried >aggregate(dataset, by=list(dataset$col5), sum) and I get the error that sum is not meaningful for factors. I want to only calculate
2000 May 31
1
legend with multiple columns
I have made a minor hack to "legend" (in R 1.0.0, but I didn't notice any changes to legend in the 1.0.1 NEWS) to allow the legend to be formatted in multiple columns, or horizontally (number of columns <- number of legend items). (I find this helpful when I have lots of legend items and not a lot of vertical space to squeeze the legend into.) (Another hack I've considered
2009 Dec 24
3
Newbie: colSums() compared with Matlab's sum()
Hi all, I'm trying to learn R after years of Matlab's experience. Here is an issue I couldn't solve today. Consider the following piece of code (written by memory): for(i in 1:n){ submat <- data[1:i,] C <- colSums(submat) } The problem is that at the first iteration, data[1:1,] reduces to a vector and colSums returns an error. This sounds really strange to me
2010 Sep 27
1
stacked area chart
Dear R-ers! Asking for your help with building the stacked area chart for the following simple data (several variables - with date on the X axis): ### Creating a data set my.data<-data.frame(date=c(20080301,20080402,20080503,20090301,20090402,20090503,20100301,20100402,20100503), x=c(1.1,1.0,1.6,1,2,1.5,2.1,1.3,1.9),y=c(-4,-3,-6,-5,-7,-5.2,-6,-4,-4.9),
2008 Feb 29
4
Column sums from a data frame (without the headers)
Does anyone know how to get a vector of column sum from a data frame? You can use colSums(), but this gives you a object of type "numeric" with the column labels in the first row, and the sums in the second row. I just want a vector of the sums, and I can't figure out a way to index the "numeric" object. Thanks!
2001 Feb 22
2
afx.h... configure: error: Could not find the MFC includes
This is driving me nuts. I'm trying to compile an MFC application using WINE. I can specify the location of the ATL includes and configure is quite happy but it chokes when I give it the MFC includes in the same way: ./configure --with-atl-includes=/home/wade/VC98/atl/Include --with-mfc-includes=/home/wade/VC98/mfc/Include Wassup? I'm using Winemaker 0.5.5 And wine
2009 Oct 14
1
change order of bar plot categories
Is this what you want? temp<-c(rep("Low",2),rep("Medium",2),rep("High",2)) light<-rep(c("Dark","light"),3) avg<-dat.avg2[,3] # se<-dat.avg2[,4] dat.avg.temp<-data.frame(cbind(avg,se)) dat.avg.temp<-data.frame(cbind(temp,light,dat.avg.temp)) dat.plot<-qplot(light,avg, fill=factor(temp),data=dat.avg.temp, geom="bar",
2011 Feb 10
1
randomly generated binary matrix (with conditions)
I want to create a randomly generated 25*15 binary matrix knowing what the colSums and rowSums of this matrix should be. colSums(a) [1] 3 7 2 5 0 4 6 5 5 4 3 4 4 5... rowSums(a) [1] 8 6 6 6 6 6 5 5 5 5 4 4 4... . . Baptiste Coulmont coulmont at yahoo.com --------
2009 Dec 29
1
extract value from first column based on value in second column
Hi all, I have two columns of data, the first consists of parameter estimates and the second probability estimates. I would like to extract the value from the first column based on the max value of column two, but not sure how to do this other than by extracting the value and then manually finding the value in the first column. Anyone know how to do this? Basically, I need to find the row
2008 Aug 11
3
tkentry that exits after RETURN?
I can set up an entry widget (thanks to an old post by Barry Rowlingson) that gets a password and exits when the user clicks on the "OK" button. Anyone have any clever ideas for returning/ destroying the window when the user types a carriage return/ENTER in the text window? I've messed around a little with validate, validatecommand, but don't see any obvious way to do it ...
2006 May 22
3
ssize_t not defined in sockconn.c (PR#8889)
Problem: Build of R failed when compiling sockconn.c. The problem seemed to be that ssize_t was not defined. The following change in sock.h fixes the problem, though it's probably not fixed the _right_ way. /* Following line changed by WTR (Cira) to overcome make problem. #if defined Win32 && !defined _SSIZE_T_ typedef int ssize_t; #endif */ typedef int ssize_t; Thanks! Wade
2011 Mar 29
4
Creating 3 vectors that sum to 1
I have 3 vectors: p1, p2, and p3. I would like each vector to be any possible value between 0 and 1 and p1 + p2 + p3 = 1. I want to graph these and I've thought about using scatterplot3d(). Here's what I have so far. library(scatterplot3d) p1 <- c(1,0,0,.5,.5,0,.5,.25,.25,.34,.33,.33,.8,.1,.1,.9,.05,.05) p2 <- c(0,1,0,.5,0,.5,.25,.5,.25,.33,.34,.33,.1,.8,.1,.05,.9,.05) p3 <-
2011 Jan 07
2
Summing over specific columns in a matrix
Hi, I would like to sum some specific columns in my matrix- for example, my matrix looks like this: [,1] [,2] [,3] [,4] [,5] [1,] 1 NA NA NA NA [2,] 2 1 NA 1 NA [3,] 3 2 1 2 1 [4,] 4 3 2 3 2 [5,] NA NA NA 4 3 [6,] NA NA NA 5 NA I would like to find the sum of the first two columns, the second two columns and