similar to: Assigning NULL to large variables is much faster than rm() - any reason why I should still use rm()?

Displaying 20 results from an estimated 4000 matches similar to: "Assigning NULL to large variables is much faster than rm() - any reason why I should still use rm()?"

2006 Nov 14
3
Creating a table
Dear R List, I am a new to R, so my question may be easy to answer for you: I have a dataframe, for example: df<-data.frame(loc=c("A","B","A","A","A"), year=as.numeric(c("1970","1970","1970","1976","1980"))) and I want to create the following table without using loops: 1970-74 ;
2002 Sep 18
2
No subject
--============_-1179735293==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" To: r-help-request@lists.R-project.org From: "Dr. Chris Wills" <cwills@ucsd.edu> Subject: Questions about sorting and functions Cc: Bcc: X-Attachments: Dear R-Gang - Two questions for you: 1) I cannot figure out how to sort one column in an array, and
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi, I have a matrix, say m=matrix(c( 983,679,134, 383,416,84, 2892,2625,570 ),nrow=3 ) i can find its row/col sum by rowSums(m) colSums(m) How do I divide each row/column by its rowSum/colSums and still return in the matrix form? (i.e. the new rowSums/colSums =1) Thanks. Casper -- View this message in context:
2011 Mar 25
2
two minor bugs in rowsum()
(a) In R 2.12.2 rowsum can overflow if given an integer input: > rowsum(c(2e9L, 2e9L), c("a", "a")) [,1] a -294967296 > 2^32 + .Last.value [,1] a 4e+09 Should it be changed to coerce its x argument to numeric (double precision) so it always returns a numeric output? (b) When rowsum is given an x containing both NaN and NA it appears to use the last
2007 Apr 16
1
colSum() in Matrix objects
Hi, I'd like to simply add column-wise using Matrix objects (Csparse). It looks like one can apply mosty any base function to these objects (i.e., apply, colSums), but there is a nasty conversion to traditional matrix objects if one does that. Is there any workaround? I can see colSum listed in the help for Class 'CsparseMatrix' , but I wonder whether I'm using the default
2008 Jul 23
8
sequential sum of a vector...
Hi R, Let, x=1:80 I want to sum up first 8 elements of x, then again next 8 elements of x, then again another 8 elements..... So, my new vector should look like: c(36,100,164,228,292,356,420,484,548,612) I used: aggregate(x,list(rep(1:10,each=8)),sum)[-1] or rowsum(x,group=rep(1:10,each=8)) But without grouping, can I achieve the required? Any other ways of doing
2007 Mar 24
1
frequency tables and sorting by rowSum
Dear list, I have some trouble generating a frequency table over a number of vectors. Creating these tables over simple numbers is no problem with table() > table(c(1,1,1,3,4,5)) 1 3 4 5 3 1 1 1 , but how can i for example turn: 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 into 0 0 1 1 1 0 0 2 0 1 0 3 My second problem is, sorting rows and columns of a matrix by the rowSums/colSums. I did it
2008 Mar 25
2
help with rowsum/aggregate type functions
Hi-- This is a question with a trivial and obvious answer, I'm sure, but I can't seem to find it in the help files and books that I have handy. I have a dataframe consisting of two columns, "Gene_Name," a list of gene symbols, and "Number," a numeric measure of how frequently a tag representing that gene showed up in a SAGE library. Several of the genes are
2001 Sep 13
1
rowsum dimnames
Hi, The result of rowsum() in R doesn't have the dimnames I'd expect, e.g.: > rowsum(matrix(1:12, 3,4), c("Y","X","Y")) [,1] [,2] [,3] [,4] 1 2 5 8 11 2 4 10 16 22 whereas S-Plus gives the more useful result: [,1] [,2] [,3] [,4] X 2 5 8 11 Y 4 10 16 22 This is because R's rowsum() code gives
2001 Sep 14
1
rowsum dimnames (PR#1092)
The result of rowsum() in R doesn't have the dimnames I'd expect, e.g.: > rowsum(matrix(1:12, 3,4), c("Y","X","Y")) [,1] [,2] [,3] [,4] 1 2 5 8 11 2 4 10 16 22 whereas S-Plus gives the more useful result: [,1] [,2] [,3] [,4] X 2 5 8 11 Y 4 10 16 22 This is because R's rowsum() code gives the
2003 Aug 13
2
rowsum() may return a vector instead of a matrix (PR#3737)
If all rows are in the same "group", rowsum() returns a vector instead of a (1xN) matrix, contrary to documentation: R> print(z <- rowsum(matrix(1:12, 3,4), rep("x",3))) [1] 6 15 24 33 R> dim(z) NULL It worked correctly in version 1.4.0 but was broken by version 1.6.1. I'm currently using 1.7.1 under Solaris 2.8. --please do not edit the information
2013 Feb 06
1
weighing proportion of rowSums in dataframe
Dear R-List, I am sure there must be a very simple way to do this - I just do not know how... This is what I want to do: #my dataframe df<-data.frame(id=c("x01","x02","x03","x04","x05","x06"),a=c(1,2,NA,4,5,6),b=c(2,4,6,8,10,NA),c=c(NA,3,9,12,NA,NA),sum=c(3,9,15,24,15,6))    id    a     b     c   sum 1 x01  1     2    NA   3 2
2003 Feb 12
2
Various Errors using Survey Package
Hi, I have been experimenting with the new Survey package. Specifically, I was trying to use some of the functions on the public-use survey data from NHIS (2000 Sample Adult file). Error 1): The first error I get is when I try to specify the complex survey design. nhis.design<-svydesign(ids=~psu, probs=~probs, strata=~strata, data=nhis.df, check.strata=TRUE) Error in svydesign(ids =
2012 Mar 23
2
R Error : DATA to MATRIX
Dear Sir/Madam, I'm getting a problem with a R-code which converts a data frame to a matrix. It first generate a (m^(n-m) * m) matrix A and then regenerate another matrix B having less dimension than A which satisfy some condition. Now I wish to assign each row of B to a vector as individual. My problem is when I set any choice of (n,m) except m=1 it works fine but setting m=1 I got the
2006 Dec 03
1
passing an argument to a function which is also to be a dataframe column name
any suggestions on the following gratefully welcome, I have a dataframe, which I am subsetting via labels atpi[, creativity] where (for example) atpi = as.data.frame(matrix(1:50, ncol = 5, nrow = 10)) names(atpi) = c("Q1", "Q2", "Q3", "Q4", "Q5") and creativity = c("Q1", "Q3", "Q4") I want to add an extra column
2006 May 12
3
optimal way to compute matrix subtotals?
Hi! I have large matrices, one column per variable and I have a vector of factors / grouping symbols. Then I am computing subtotals for the groups but it takes pretty long and thus I wanted to ask if there is a better way to do it or if this is already the best way: subTotals <- function(x, groupvec) do.call("rbind",lapply(split(x,groupvec),colSums,na.rm=T)) Thanks reading my
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
2016 Sep 15
2
row names of 'rowsum()'
'rowsum()' seems to add row names to the resulting matrix, corresponding to the respective 'group' values. This is very handy, but it is not documented. Should the documentation mention it so it could be relied upon as part of API? Cheers, Ott -- Ott Toomet Visiting Researcher School of Information Mary Gates Hall, Suite 310 University of Washington Seattle, WA 98195
2010 Oct 20
2
rowsum
Hello, I am trying to achieve something which I *think* is possible using rowsum, but a little help should be useful: Consider the following dataframe DF0: A B C 89 1 140 89 06 20 89 29 137 89 52 13 89 57 10 89 97 23 89 1 37 89 1 12 89 1 3 52 1 11 52 1 31 52 1 16 52 1 6 52 1 10 52 1 13 52 1 10 52 1 25 52 1 2 52 59 38 52 97 75 57 1 14 57 1 13 57 1 14 57 114 12 57 1 23 57 06 26 I need create a
2012 Oct 30
4
There is pmin and pmax each taking na.rm, how about psum?
Hi, Please consider the following : x = c(1,3,NA,5) y = c(2,NA,4,1) min(x,y,na.rm=TRUE) # ok [1] 1 max(x,y,na.rm=TRUE) # ok [1] 5 sum(x,y,na.rm=TRUE) # ok [1] 16 pmin(x,y,na.rm=TRUE) # ok [1] 1 3 4 1 pmax(x,y,na.rm=TRUE) # ok [1] 2 3 4 5 psum(x,y,na.rm=TRUE) [1] 3 3 4 6 # expected result Error: could not find function "psum" # actual result