search for: byappli

Displaying 9 results from an estimated 9 matches for "byappli".

Did you mean: byapply
2018 Feb 20
5
Take the maximum of every 12 columns
Dear all, I have monthly data in wide format, I am only providing data (at the bottom of the email) for the first 24 columns but I have 2880 columns in total. I would like to take max of every 12 columns. I have taken the mean of every 12 columns with the following code: byapply <- function(x, by, fun, ...) { # Create index list if (length(by) == 1) { nc <- ncol(x)
2018 Feb 20
3
Take the maximum of every 12 columns
This is what I was looking for. Thank you everyone! Sincerely, Milu <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Mail priva di virus. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
2018 Feb 20
0
Take the maximum of every 12 columns
Hi Milu, byapply(df, 12, function(x) apply(x, 1, max)) You might also be interested in the matrixStats package. Best, Ista On Tue, Feb 20, 2018 at 9:55 AM, Miluji Sb <milujisb at gmail.com> wrote: > Dear all, > > I have monthly data in wide format, I am only providing data (at the bottom > of the email) for the first 24 columns but I have 2880 columns in total. > > I
2018 Feb 20
0
Take the maximum of every 12 columns
Thank you for your kind replies. Maybe I was not clear with my question (I apologize) or I did not understand... I would like to take the max for X0...X11 and X12...X24 in my dataset. When I use pmax with the function byapply as in byapply(df, 12, pmax) I get back a list which I cannot convert to a dataframe. Am I missing something? Thanks again! Sincerely, Milu
2018 Feb 20
0
Take the maximum of every 12 columns
Ista, et. al: efficiency? (Note: I needed to correct my previous post: do.call() is required for pmax() over the data frame) > x <- data.frame(matrix(runif(12e6), ncol=12)) > system.time(r1 <- do.call(pmax,x)) user system elapsed 0.049 0.000 0.049 > identical(r1,r2) [1] FALSE > system.time(r2 <- apply(x,1,max)) user system elapsed 2.162 0.045 2.207 ##
2018 Feb 20
2
Take the maximum of every 12 columns
Don't do this (sorry Thierry)! max() already does this -- see ?max > x <- data.frame(a =rnorm(10), b = rnorm(10)) > max(x) [1] 1.799644 > max(sapply(x,max)) [1] 1.799644 Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic
2018 Feb 20
2
Take the maximum of every 12 columns
On Tue, Feb 20, 2018 at 11:58 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > Ista, et. al: efficiency? > (Note: I needed to correct my previous post: do.call() is required for > pmax() over the data frame) > > > x <- data.frame(matrix(runif(12e6), ncol=12)) > > > system.time(r1 <- do.call(pmax,x)) > user system elapsed > 0.049 0.000
2018 Feb 20
0
Take the maximum of every 12 columns
It looks like OP uses a data.frame, so in order to use matrixStats (I'm the author) one would have to pay the price to coerce to a matrix before using matrixStats::rowMaxs(). However, if it is that the original data could equally well live in a matrix, then matrixStats should be computational efficient for this task. (I've seen cases where an original matrix was turned into a data.frame
2018 Feb 20
0
Take the maximum of every 12 columns
The maximum over twelve columns is the maximum of the twelve maxima of each of the columns. single_col_max <- apply(x, 2, max) twelve_col_max <- apply( matrix(single_col_max, nrow = 12), 2, max ) ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie