Skip to content

Help with multiple use of "quantile"

4 messages · Parodi, Pietro, Adams, Jean, arun +1 more

#
HI,
You could also use:

set.seed(24)
aaa <- matrix(rnorm(60), ncol=3)
bbb <- matrix(runif(15), ncol=3)
ccc1<- mapply(quantile,as.data.frame(aaa),as.data.frame(bbb))
ccc <- sapply(1:dim(aaa)[2], function(i) quantile(aaa[, i], bbb[, i])) #Jean's solution

colnames(ccc1)<-NULL

? identical(ccc,ccc1)
#[1] TRUE
A.K.



----- Original Message -----
From: "Adams, Jean" <jvadams at usgs.gov>
To: "Parodi, Pietro" <Pietro.Parodi at willis.com>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Saturday, June 8, 2013 9:49 AM
Subject: Re: [R] Help with multiple use of "quantile"

Try this, Pietro ...

# example data
aaa <- matrix(rnorm(60), ncol=3)
bbb <- matrix(runif(15), ncol=3)

# calculate quantiles
ccc <- sapply(1:dim(aaa)[2], function(i) quantile(aaa[, i], bbb[, i]))
# change rownames
rownames(ccc) <- seq(dim(ccc)[1])

Jean
On Sat, Jun 8, 2013 at 8:20 AM, Parodi, Pietro <Pietro.Parodi at willis.com>wrote:

            
??? [[alternative HTML version deleted]]

______________________________________________
R-help at 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.
#
Hello,

And you really don't need colnames(ccc1) <- NULL, there's a USE.NAMES 
argument to mapply. Just set it to FALSE.

Rui Barradas

Em 08-06-2013 18:28, arun escreveu: