search for: aaply

Displaying 20 results from an estimated 20 matches for "aaply".

Did you mean: aapl
2010 Oct 03
1
plyr: a*ply with functions that return matrices-- possible bug in aaply?
...), 1:(C-1)] } Now, I want to extend this to higher-way arrays, using apply-like methods over the strata (all but the first two dimensions), and returning an array in which the last dimensions correspond to strata. That is, I want to define something like the following using an a*ply method, but aaply gives a result in which the applied .margin(s) do not appear last in the result, contrary to the documentation for ?aaply. I think this is a bug, either in the function or the documentation, but perhaps there's something I misunderstand for this case. fun <- function(f, stratum=NULL) {...
2013 Apr 29
0
interesting behavior from aaply
Dear helpers, I'm using plyr to process a large matrix for the first time. My code is set up to work with matrixes, since I learned the hard way that dataframes are considerably slower to process. I started using aaply(), but the data was rearranged from a flat matrix to a [, , 4] array for larger input matrixes. I'm sure something clever is happening that I'm just not seeing - anyone have any insight? I can provide the code for index.frames() if you like, but it's pretty turgid stuff. For now I'...
2010 Apr 18
3
xtabs() of proportions, and naming a dimension (not a row)
...able of proportions -- that is, I want to divide every vector (along a particular dimension) by its sum. The tiny example below does that. The call to xtabs() creates a matrix "A" with dimensions ("x1","x2","y"). I transform "A" using aperm() and aaply() to get the matrix "B". The problem: "B" has dimensions (<No name>, "x2", "x1"). How can I give (back) the name "y" to the dimension with no name in the matrix "B"? (Unless I misunderstand something, dimnames() won't do it --...
2009 Mar 13
4
Sorting rows of a matrix independent of each other
Oh, this seemed so simple (and I'm sure the answer will be, as usual, so thanks in advance for enlightening me). I need to sort each row of a matrix independent of the others. For example, > test <- matrix(c(8,7,1,2,6,5,9,4,3),nrow=3) > test [,1] [,2] [,3] [1,] 8 2 9 [2,] 7 6 4 [3,] 1 5 3 I can get each row sorted well enough. > sort(test[1,]) [1]
2012 Dec 05
3
data manipulation between vector and matrix
Dear list, I was curious how to subtract a vector from matrix? Say, I have mat <- matrix(1:40, nrow=20, ncol=2) x <-c(1,2) I want, x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements of x against column elements in mat. But x-mat won't do it. Thanks, Mike [[alternative HTML version deleted]]
2011 Nov 10
2
Listing tables together from random samples from a generated population?
. HI there, I'd like to show demonstrate how the chi-squared distribution works, so I've come up with a sample data frame of two categorical variables y<-data.frame(gender=sample(c('Male', 'Female'), size=100000, replace=TRUE, c(0.5, 0.5)), tea=sample(c('Yes', 'No'), size=100000, replace=TRUE, c(0.5, 0.5))) And I'd like to create a list of 100
2013 Apr 10
6
means in tables
Hi. I have 2 tables, with same dimensions (8000 x 5). Something like: tab1: V1 V2 V3 V4 V5 14.23 1.71 2.43 15.6 127 13.20 1.78 2.14 11.2 100 13.16 2.36 2.67 18.6 101 14.37 1.95 2.50 16.8 113 13.24 2.59 2.87 21.0 118 tab2: V1 V2 V3 V4 V5 1.23 1.1 2.3 1.6 17 1.20 1.8 2.4 1.2 10 1.16 2.6 2.7 1.6 11 1.37 1.5 2.0 1.8 13 1.24 2.9 2.7 2.0 18 I need generate a table of averages, the
2008 Sep 30
0
New package: plyr
...ype of object they input (first letter) and output (second letter): * llply = from a list to a list * alply = from an array (or vector, or matrix) to a list * ldply = from a list to a data.frame * d_ply = from a data.frame, ignore output * and so on for llply, laply, ldply, l_ply, alply, aaply, adply, a_ply, dlply, daply, dply, d_ply plyr also provides: * m*ply which works in a similar way to mapply * r*ply which works in a similar way to replicate You can find out more at http://had.co.nz/plyr/, including a 20 page introductory guide, http://had.co.nz/plyr/plyr-intro.pdf. Regard...
2010 Jan 20
1
min and max operations on matrix
Folks, I've got a matrix x as follows: > x <- matrix(c(1,2,3,5,3,4,3,2,1), ncol = 3, byrow = TRUE) > x [,1] [,2] [,3] [1,] 1 2 3 [2,] 5 3 4 [3,] 3 2 1 In each row of x, I want to replace the minimum value by -1, the maximum value by +1 and all other values by 0. So in the above case I want to end up as follows: [,1] [,2] [,3] [1,] -1 0
2008 Sep 30
0
New package: plyr
...ype of object they input (first letter) and output (second letter): * llply = from a list to a list * alply = from an array (or vector, or matrix) to a list * ldply = from a list to a data.frame * d_ply = from a data.frame, ignore output * and so on for llply, laply, ldply, l_ply, alply, aaply, adply, a_ply, dlply, daply, dply, d_ply plyr also provides: * m*ply which works in a similar way to mapply * r*ply which works in a similar way to replicate You can find out more at http://had.co.nz/plyr/, including a 20 page introductory guide, http://had.co.nz/plyr/plyr-intro.pdf. Regard...
2008 Dec 18
1
Newbie "if" problem
I have got a general problem when applying a function to a dataframe using the function; Apply(df,1,myfunct) Where myfunct has an IF statement in it along the lines of; If (z == 0) X = 1 If (z ==0) Z = 1 I.e. Two If statements Is there something I am missing or have a just formed the if statements wrong ­ just checking there is not some trick you have to use when using apply with functions
2011 Sep 20
1
means across list of data frames
I have a list of data frames like the following: set.seed(123) a<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10)) b<- data.frame(x=runif(10), y = runif(10), sample = seq(1,10)) L<- list(a,b) All data frames in the list have the same dimensions. I need to calculate the sample means for x and y. The real data are lists of several thousand quite large dataframes, so I need
2012 Jan 12
1
parallel computation in plyr 1.7
Dear all, I have a question regarding the possibility of parallel computation in plyr version 1.7. The help files of the following functions mention the argument '.parallel': ddply, aaply, llply, daply, adply, dlply, alply, ldply, laply However, the help files of the following functions do not mention this argument: ?d_ply, ?aply, ?lply Is it because parallel computation is not supported for these latter functions? Or is it just because the documentation was not updated for these...
2011 Feb 15
1
matrixStats: Extend to arrays too (Was: Re: Suggestion: Adding quick rowMin and rowMax functions to base package)
Hi. On Sun, Feb 13, 2011 at 10:18 AM, TakeoKatsuki <takeo.katsuki at gmail.com> wrote: > > Hi Henrik, > > It would be nice if functions of the matrixStats package can handle array > data. > For example, rowSums() of the base package sums along the third axis of an > array by rowSums(x, dim=2). That is a good idea. This was indeed the initial objective before starting
2013 Mar 22
1
Median across matrices
Hey all, I have a list of matrices. I'd like to calculate the median across all those matrices for each element. What I'd like to end up with is a matrix containing the median of all [1,1] [1,2] etc. elements across all matrices. Is there a concise way of doing that? Thanks!
2009 Apr 15
0
plyr version 0.1.7
...* massive speed ups for splitting large arrays * fixed typo that was causing a 50% speed penalty for d*ply * rewritten rbind.fill is considerably (> 4x) faster for many data frames * colwise about twice as fast Bug fixes: * daply: now works when the data frame is split by multiple variables * aaply: now works with vectors * ddply: first variable now varies slowest as you'd expect plyr 0.1.5 (2008-02-23) --------------------------------------------------- * colwise now accepts a quoted list as its second argument. This allows you to specify the names of columns to work on: colwise(mean...
2009 Apr 15
0
plyr version 0.1.7
...* massive speed ups for splitting large arrays * fixed typo that was causing a 50% speed penalty for d*ply * rewritten rbind.fill is considerably (> 4x) faster for many data frames * colwise about twice as fast Bug fixes: * daply: now works when the data frame is split by multiple variables * aaply: now works with vectors * ddply: first variable now varies slowest as you'd expect plyr 0.1.5 (2008-02-23) --------------------------------------------------- * colwise now accepts a quoted list as its second argument. This allows you to specify the names of columns to work on: colwise(mean...
2013 Jan 16
4
Changing frequency values to 1 and 0
Dear list, I'm working with a large data set, where I grouped several species in one group (guild). Then I reshaped my data as shown below. Now, I just want to have "Rep" only as 1 or 0. I'm not being able to change the values of rep>=1 to 1... tried many things and I'm not being successful! > melting=melt(occ.data,id.var=c("guild", "Site",
2010 Jan 25
5
Data transformation
Dear all, I have a dataset that looks like this: x <- read.table(textConnection("col1 col2 3 1 2 2 4 7 8 6 5 10"), header=TRUE) I want to rewrite it as below: var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 1 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 0 0
2010 Jan 19
4
apply command
Can you please help on the issue? I using the apply command on a matrix below the example: Create a vector x =c(5, 3, 2:4, NA, 7, 3, 9, 2, 1, 5) create a matrix of 2 rows by 6 columns b=matrix(x, 2,6) print(b) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 5 2 4 7 9 1 [2,] 3 3 NA 3 2 5 using the command apply print(apply(b, 1, function(y) sort(y, na.last=F))) the