similar to: aggregate arrays

Displaying 20 results from an estimated 20000 matches similar to: "aggregate arrays"

2003 Jul 30
6
reverse array indexing
Hi, Suppose I have a multidimensional array: tmp <- array(1:8, c(2,2,2)) is there a function out there that, given a one-dimensional array index, will return the separate indices for each array dimension? for instance, tmp[8] is equivalent to tmp[2,2,2]. I'd like to derive the vector (2,2,2) from the index 8. thanks, Brad Buchsbaum
2009 Sep 27
2
zoo: merging aggregated zoo-objects fails
Dear all, I have several text files looking like this: 9063032 19700201 22:00 174.067 9063032 19700201 23:00 174.076 9063032 19700202 00:00 174.085 9063032 19700202 01:00 174.091 9063032 19700202 02:00 174.094 9063032 19700202 03:00 174.091 9063032 19700202 04:00 174.082 9063032 19700202 05:00 174.079 And I run this loop: for (j in 1:nr.of.files) { #Import: DF <-
2006 Feb 11
2
aggregate vs tapply; is there a middle ground?
Dear all, I'm wanting to do a series of comparisons among 4 categorical variables: a <- aggregate(y, list(var1, var2, var3, var4), sum) This gets me a very nice 2-dimensional data frame with one column per variable, BUT, as help for aggregate says, <<empty subsets are removed>>. I don't see in help(aggregate) how I can change this. In contrast, a <- tapply(y,
2003 Dec 04
6
get mean of several rows
Dear all! After hours of trying around, I gave up: I have a 2-dimensional array, and I know how to split it into its rows and how to get the mean for every row using 'sapply'. But what I want is to calculate the mean over the first n rows, and then the second n rows, etc., so that I get a vector like: v == mean1(row 1:5), mean2(row6:10),... (trivial, you might say. I find it rather
2011 Jan 17
1
how to cut a multidimensional array along a chosen dimension and store each piece into a list
Dear R-Helpers, I wonder whether there is a function which cuts a multiple dimensional array along a chosen dimension and then store each piece (still an array of one dimension less) into a list. For example, arr <- array(seq(1*2*3*4),dim=c(1,2,3,4)) # I made a point to set the length of the first dimension be 1to test whether I worry about drop=F option. brkArrIntoListAlong <-
2010 Mar 29
3
about data export
Hello all, This is Meghana. Well, I have some analysis output in 3 dimensional array form. for example: , , type1 A B C D 1 2 3 4 1 2 3 4 , , type2 etc. This array is very big. and I want to export this to either text form or excel(csv is preffered) so that different parts of aaray should be easily extractable from that excel/text sheet. How can I go about it? Thank
2007 May 21
3
an array of matrices
I'd like to have a three dimensional array of matrices. I thought I could construct a five dimensional array to have the three dimensional array of matrices. However, not all of the matrices in the array have the same dimensions, which seems to mean I can't use a five dimensional array. What I'd like is this: A = matrix(1:4,2,2) B = matrix(1:25,5,5) C = matrix(1,3,3) D =
2004 Apr 14
1
Aggregate drops empty subsets
Greetings, R community. I am trying to create a multi-dimensional contingency table suitable for analysis by glm() using the poisson family. I have three factors, each with four levels, with some observed zeros. I'm trying to use aggregate to construct my contingency table, but it drops empty subsets, so the zeros get lost. I also tried tapply() but it doesn't carry over the main
2017 Jun 01
5
Reversing one dimension of an array, in a generalized case
Hi All: I have been looking for an elegant way to do the following, but haven't found it, I have never had a good understanding of any of the "apply" functions. A simplified idea is I have an array, say: junk(5, 10, 3) where (5, 10, 3) give the dimension sizes, and I want to reverse the second dimension, so I could do: junk1 <- junk[, rev(seq_len(10), ] but what I am
2009 May 09
1
Improve aggregate.default ...?
Hi, I find it a bit annoying that aggregate.default forces the returned object to loose the 'name' of the variable aggregated, replacing it with 'x'. A brief example: > dat <- data.frame(A = runif(100), B = rnorm(100), + Group = gl(4, 25)) > with(dat, aggregate(A, by = list(Group = Group), FUN = mean)) Group x 1 1 0.6523228 2 2
2017 Jul 14
3
Making 2 dimensional vector from the 3 dimensional one
Hi All, I want to make a 1 dimension vector from the first two dimensions of a 3 dimension array, so make a 2 dimension vector from a 3-dimension one, with "fusing" (making as.vector) the first two dimensions. It seems to be very easy, but I cannot find the solution, I mean it would very strange, that I would do taking the single 1 dimensional vectors from the 3 dimensional one, make one
2009 Nov 23
3
FUN argument to return a vector in aggregate function
Hi All, I am currently doing the following to compute summary statistics of aggregated data: a = aggregate(warpbreaks$breaks, warpbreaks[,-1], mean) b = aggregate(warpbreaks$breaks, warpbreaks[,-1], sum) c = aggregate(warpbreaks$breaks, warpbreaks[,-1], length) ans = cbind(a, b[,3], c[,3]) This seems unnecessarily complex to me so I tried > aggregate(warpbreaks$breaks, warpbreaks[,-1],
2001 Oct 30
2
creating chron object aggregates (e.g. sums by day)
What is the recommended/optimal way to perform aggregates on data frames with chron objects? Here is an example: >raw.data 1 07/09/01 4000 2 07/09/01 2000 3 07/11/01 1000 4 07/13/01 800 5 07/13/01 700 6 07/16/01 600 7 07/17/01 500 I'm trying to construct a function that would first aggregate the data (second column) by day (grouping by the first column) according to a
1997 Apr 02
1
R-beta: Three-dimensional arrays
I get a segmentation fault when I access labelled three-dimensional arrays: > new.array<-array((1:27),c(3,3,3)) > new.array[,1,] [,1] [,2] [,3] [1,] 1 10 19 [2,] 2 11 20 [3,] 3 12 21 > label<-c("l1","l2","l3") > new.array<-array((1:27),c(3,3,3),list(label,label,label))
2010 Apr 20
1
bug in aggregate.ts
Hi, I am getting unexpected behaviour from aggregate.ts(). The 'ndeltat' argument is effectively being reduced by 1 in some cases, even when it is an integer, with the result that the blocks to be aggregated are not of the expected size, and also that the end() of the aggregated series is much later than the end() of the original series. rawts <- ts(rep(1:10, each = 5), start = 1) ##
2011 Sep 27
1
array extraction
hello everyone. Look at the following R idiom: a <- array(1:30,c(3,5,2)) M <- (matrix(1:15,c(3,5)) %% 4) < 2 a[M,] <- 0 Now, I think that "a[M,]" has an unambiguous meaning (to a human). However, the last line doesn't work as desired, but I expected it to...and it recently took me an indecent amount of time to debug an analogous case. Just to be explicit, I would
2011 Jul 14
2
cbind in aggregate formula - based on an existing object (vector)
Hello! I am aggregating using a formula in aggregate - of the type: aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata) However, I actually have an object (vector of my variables to be aggregated): myvars<-c("var1","var2","var3") I'd like my aggregate formula (its "cbind" part) to be able to use my "myvars" object. Is it
2006 Jan 02
9
Generating nice tables
Making tables in templates is pretty easy, except for one minor problem. They tend to be fairly ugly. If you have a model with three attributes, it''s very easy to create an html table that looks like this.. Col1 Col2 Col3 A B D A B E A C F A C G Which becomes difficult to read when you have a lot of repeated data. What I would really like to generate
2010 Apr 22
3
using which to select range of values
Hi all, I would like to get the array index for a range of values, say 0 < x < 1.5. I'm wondering if there is an alternative for the following which I've done x0 <- rnorm(100) x1 <- ifelse(x0 > 0 & x0 < 1.5,"t","f") x2 <- which(x1=="t",arr.ind=TRUE) x0[x2] Thanks. -- Muhammad
2010 Feb 08
3
Hypercube in R
Dear all, Does anybody have an idea or suggestion how to construct (plot) 4-dimensional hypercube in R. Thanks in advance for any pointers. Regards, Andrej