[R] rownames cannot allocate vector of size
Hi, On R 2.10.1 for Windows, when I do the following to duplicate the structure of a large numeric matrix called matrix1: matrix2 - matrix(0,nrow=nrow(matrix1),ncol=ncol(matrix1)) and then rownames(matrix2) - rownames(matrix1) I get a cannot allocate vector of size xxMb error but if I instead do: rnames - list() rnames - rownames(matrix1) matrix2 - matrix(0,nrow=nrow(matrix1),ncol=ncol(matrix1),dimnames=rnames) I get no error. Of course both approaches work in R on Unix without memory limits. But I'm intrigued about the apaprent difference in memory usage/allocation for the two above approaches. Is there any explanation for this difference in behaviour? thanks Tony __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] counting repeating sequence lengths in a vector
Hello, I have a very long (~50,000) sequence of repeating numbers. The first 100 are: [1] 0 0 0 0 0 0 0 0 0 0 0 429 [13] 429 429 429 429 429 429 429 858 858 858 858 858 [25] 858 1287 1287 1287 1287 1287 1716 2145 2145 2574 2574 3003 [37] 3003 3432 3432 3861 4290 4719 5148 5577 5577 6006 6006 6006 [49] 6435 6435 6435 6864 6864 7293 7293 7293 7722 7722 7722 7722 [61] 8151 8151 8151 8580 8580 8580 9009 9009 9009 9009 9438 9438 [73] 9438 9438 9867 9867 9867 10296 10296 10296 10725 10725 10725 10725 [85] 11154 11154 11154 11154 11154 11583 11583 11583 11583 12012 12012 12012 [97] 12012 12441 12441 12441 What I want is to produce a vector of lengths for each contiguous run of numbers . i.e. for the above example, the first three items of the vector returned would be: 11 8 6 ...to represent the counts of 0, 429, and 585, respectively. I could do this with unique() and a for loop, but this would be very inefficient. Any advice on how to do this efficiently would be most appreciated. thanks Tony __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extract clusters from a hclusrt object without cutree
Hello, I am generating an hclust() object and want to extract a subset of clusters WITHOUT using cutree(). I see this somehow involves using the $merge matrix to associate $labels into their appropriate clusters where clusters are split below a given $height threshold. Can anyone suggest a way/code to do this? I see cutree uses embedded fortran code, so it's not obvious how cutree does it thanks Tony __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.