search for: pmin

Displaying 20 results from an estimated 260 matches for "pmin".

Did you mean: min
2003 Jan 31
2
minor error in documentation of pmax in base (PR#2513)
The documentation says, "pmax and pmin take several vectors as arguments and return a single vector giving the parallel maxima (or minima) of the vectors." I discovered that, if you use a matrix or array instead of a vector, pmax returns a matrix or array, respectively. This makes pmax and pmin much more useful, and should not be...
2012 Oct 30
4
There is pmin and pmax each taking na.rm, how about psum?
Hi, Please consider the following : x = c(1,3,NA,5) y = c(2,NA,4,1) min(x,y,na.rm=TRUE) # ok [1] 1 max(x,y,na.rm=TRUE) # ok [1] 5 sum(x,y,na.rm=TRUE) # ok [1] 16 pmin(x,y,na.rm=TRUE) # ok [1] 1 3 4 1 pmax(x,y,na.rm=TRUE) # ok [1] 2 3 4 5 psum(x,y,na.rm=TRUE) [1] 3 3 4 6 # expected result Error: could not find function "psum" # actual result I realise that + is already like psum, but what about NA? x+y [1] 3 NA NA 6...
2015 Dec 24
2
override pmin/pmax for my own matrix
Hello, I'm trying to override pmin and pmax for my own matrix. These two functions have ... as an argument. I tried to override them as follows: setMethod("pmax", class_name, function(x, ..., na.rm) { ... }) I use this way to override primitive functions such as min/max and it works fine. But it doesn't work for p...
2004 Dec 22
2
outer(-x, x, pmin) cannot allocate
R> x <- 0. + 1:8000 R> y <- outer(-x, x, pmin) Error: cannot allocate vector of size 1000000 Kb Why does R need to allocate a gigabyte to create an 8000 x 8000 matrix? It doesn't have any trouble with outer(-x, x, "+"). Thanks. -- David Brahm (brahm at alum.mit.edu) Version: platform = i686-pc-linux-gnu arch = i686 os = li...
2011 Oct 04
1
a question about sort and BH
...-7a--THOC2 0.447714054 0.000479322 hsa-let-7a--SMG7 0.444972282 0.000524129 2. I got the p.adjust.R from R source. In the method "BH", I am not clear with the code: i <- lp:1L o <- order(p, decreasing = TRUE) ro <- order(o) pmin(1, cummin( n / i * p[o] ))[ro] How to explain the first and the fourth row. ====================p.adjust.R======================================= p.adjust.methods <- c("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "f...
2008 Jul 04
2
create a zero matrix & fill
...t(x) :Object cannot be transformed in double) > plot(Variation[1],Variation[2]) Fehler in as.double.default(x) : (list) Objekt kann nicht nach 'double' umgewandelt werden Any suggestion? Hier is the function: #Computing variation of the power VAR<-function(power,length){ tvar=pmean=pmin=pmax=varmax=varmin<-matrix(data=0,ncol=(length-tml0)) for(i in tml0:length){ tvar[i]=i pmean[i]=mean(power[i:(i+deltat)]) pmin[i]=min(power[i:(i+deltat)]) pmax[i]=max(power[i:(i+deltat)]) varmax[i]=100*(pmax[i]-pmean[i])/pmean[i] varmin[i]=100*(pmean[i]-pmin[i])/pmean[i] Results=list(tvar,pmean,...
2005 Dec 20
0
pmin(), pmax() - slower than necessary for common cases
...few hours ago, I was making a small point on the R-SIG-robust mailing list on the point that ifelse() was not too efficient in a situation where pmax() could easily be used instead. However, this has reminded me of some timing experiments that I did 13 years ago with S-plus -- where I found that pmin() / pmax() were really relatively slow for the most common case where they are used with only two arguments {and typically one of the arguments is a scalar; but that's not even important here}. The main reason is that the function accept an arbitrary number of arguments and that they do recycli...
2005 Apr 14
0
predict.glm(..., type="response") dropping names (and a propsed (PR#7792)
...) valideta <- function(eta) all(eta>0) } else @@ -36,7 +36,7 @@ linkfun <- function(mu) log(mu/(1 - mu)) linkinv <- function(eta) { thresh <- -log(.Machine$double.eps) - eta <- pmin(thresh, pmax(eta, -thresh)) + eta <- pmin(pmax(eta, -thresh), thresh) exp(eta)/(1 + exp(eta)) } mu.eta <- function(eta) { @@ -52,7 +52,7 @@ linkfun <- function(mu) qnorm(mu)...
2015 Mar 25
2
[LLVMdev] Optimization puzzle...
...bc' > target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" > target triple = "x86_64-apple-macosx10.10.0" > > ; Function Attrs: nounwind readnone ssp uwtable > define { <2 x float>, float } @_Z18sampleNullOperator5PointS_(i64 %pmin.coerce0, i32 %pmin.coerce1, i64 %pmax.coerce0, i32 %pmax.coerce1) #0 { > _ZN15SamplingClosureD1Ev.exit: > %0 = icmp sgt i32 %pmin.coerce1, %pmax.coerce1 > ret { <2 x float>, float } zeroinitializer > } > > attributes #0 = { nounwind readnone ssp uwta...
2015 Mar 25
3
[LLVMdev] Optimization puzzle...
...-m:o-i64:64-f80:128-n8:16:32:64-S128" >> > target triple = "x86_64-apple-macosx10.10.0" >> > >> > ; Function Attrs: nounwind readnone ssp uwtable >> > define { <2 x float>, float } @_Z18sampleNullOperator5PointS_(i64 >> %pmin.coerce0, i32 %pmin.coerce1, i64 %pmax.coerce0, i32 %pmax.coerce1) #0 >> { >> > _ZN15SamplingClosureD1Ev.exit: >> > %0 = icmp sgt i32 %pmin.coerce1, %pmax.coerce1 >> > ret { <2 x float>, float } zeroinitializer >> > } >> >...
2005 Jan 21
4
which.pmin?
...frame(rbind(fpr.floor,fpr.ceiling)), which.min) opt.k <- cbind(k.floor,k.ceiling)[1:length(ind)+length(ind)*(ind-1)] opt.k is the vector I want, but I guess I abuse some functions here. I'd like to ask the experts, What is the proper R-way to do this? The API should be like "which.pmin(FUN, X, Y, ...)" that returns a vector of the same length as X (and Y), provided that X, Y, ... have the same length. Please fill the function body. Seung
2015 Dec 24
0
override pmin/pmax for my own matrix
...e="...") setMethod("pmax", "Class", function(..., na.rm=FALSE) { }) One caveat is that all arguments passed via "..." must derive from the class specified for "..." in the method signature. At some point we should solve that by introducing a binary pmin2, pmax2 as we have for cbind and rbind. On Thu, Dec 24, 2015 at 5:54 AM, Da Zheng <zhengda1936 at gmail.com> wrote: > Hello, > > I'm trying to override pmin and pmax for my own matrix. These two > functions have ... as an argument. I tried to override them as > follows: &...
2010 Apr 23
0
dot dot dot and NextMethod
Hello, Within the development of a package, I would need to build a specific method for the "pmin" function. I first make "pmin" generic pmin <- function (..., na.rm = FALSE) UseMethod("pmin") pmin.default <- base::pmin Now, within my new method, I would like to change the arguments in . (dot dot dot) before sending it to the NextMethod. pmin....
2010 Mar 29
1
Suggestion: Adding quick rowMin and rowMax functions to base package
...add quick functions that calculate the min or max over rows / cols in a matrix. While apply(x,1,min) works, I found out by profiling a program of mine that it is rather slow for matrices with a very large number of rows. A quick functionality seems to be already there in the functions pmax and pmin, but it is rather cumbersume to apply them to all columns of a matrix (if one does not know how many columns the matrix has). Below, I have some code that shows a very unelegant implementation that illustrates possible speed gains if apply could be avoided: rowMin = function(x) { # Constr...
2008 May 02
0
Adaptive design code
...;t.first) eventfirst.a<-sum(y.a<t.first) ### Calculate conditional power at interim look under the original design # estimate median survival for both groups at first look = number of events # divided by sum of patient time at interim look (linearized rate) patTime.0<- sum(pmin((y.0-start.0)[start.0<t.first],t.first-start.0[start.0<t.first])) patTime.a<- sum(pmin((y.a-start.a)[start.a<t.first],t.first-start.a[start.a<t.first])) #patTime.0<- sum(t.first-start.0[start.0<t.first]) #patTime.a<- sum(t.first-start.a[start.a<t.first]) med...
2008 May 13
2
array dimension changes with assignment
...t remove the dimension attribute? > GT <- array(dim = c(6,nrow(InData),ncol(InSNPs))) > dim(GT) [1] 6 3178 93 > SNP1 <- InSNPs[InData[,"C1"],] > dim(SNP1) [1] 3178 93 > SNP2 <- InSNPs[InData[,"C2"],] > dim(SNP2) [1] 3178 93 > dim(pmin(SNP1,SNP2)) [1] 3178 93 > GT[1,,] <- pmin(SNP1,SNP2) > dim(GT) NULL # why?????????????????????????????????????? > GT[2,,] <- pmax(SNP1,SNP2) Error in GT[2, , ] <- pmax(SNP1, SNP2) : incorrect number of subscripts Knut M. Wittkowski, PhD,DSc ----------------------------...
2008 Dec 04
2
How to optimize this codes ?
How to optimize the for-loop to be reasonably fast for sample.size=100000000 ? You may want to change sample.size=1000 to have an idea what I am achieving. set.seed(143) A <- matrix(sample(0:1, sample.size, TRUE), ncol=10, dimnames=list(NULL, LETTERS[1:10])) B <- list() for(i in 1:10) { B[[i]] <- apply(combn(LETTERS[1:10], i), 2, function(x) { sum(apply(data.frame(A[,x]), 1,
1997 Apr 01
0
R-alpha: R-testers: pmin heisenbug
I must admit to being baffled by this. When I type "R" I get R : Copyright 1997, Robert Gentleman and Ross Ihaka Version 0.50 Beta (April 1, 1997) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type "license()" for details. > gc() Garbage collection ... 150427 cons cells free (75%) 1823k
2008 Jul 04
1
initialize a matrix
Dear R users, I'm trying to write a function which returns minimum,maximum,mean of a vector(power) I've done the following : VAR<-function(power,length){ for(i in tml:length)){ tvar[i]<-i pmean[i]<-mean(power[i:i+deltat]) pmin[i]<-min(power[i:i+deltat]) pmax[i]<-max(power[i:i+deltat]) varmax[i]<-100*(pmax[i]-pmean[i])/pmean[i] varmin[i]<-100*(pmean[i]-pmin[i])/pmean[i] Resulats<-list(tvar,pmin,pmax,pmean,varmin,varmax) }} p.s. tml is a variable which is grater than 0 , deltat is a constant defined The pr...
2010 Sep 21
5
Combined plot: Scatter + density plot
...tor.free.fr/graphiques/RGraphGallery.php?graph=78 I wonder if anybody perhaps has already developed code for this and is willing to share. This is the reproducible code for the histogram version obtained from the site: def.par <- par(no.readonly = TRUE) # save default, for resetting... x <- pmin(3, pmax(-3, rnorm(50))) y <- pmin(3, pmax(-3, rnorm(50))) xhist <- hist(x, breaks=seq(-3,3,0.5), plot=FALSE) yhist <- hist(y, breaks=seq(-3,3,0.5), plot=FALSE) top <- max(c(xhist$counts, yhist$counts)) xrange <- c(-3,3) yrange <- c(-3,3) nf <- layout(matrix(c(2,0,1,3),2,2,byrow...