search for: pmax

Displaying 20 results from an estimated 269 matches for "pmax".

Did you mean: max
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 shou...
2010 Sep 07
0
AHRQ - Creation of Comorbidity Variables
...ndrg = c(305, paste(0, 79, sep = "")) psydrg = c(885) obesedrg = c(619:621) deprsdrg = c(881) ### FLAG ################################################################### flag = matrix(0, 1, 30) tmp = matrix(0, 1, 10) for (i in 2:50) { flag[1, 1] = pmax(flag[1, 1], as.numeric(c(DX[1, i] %in% chf))) flag[1, 2] = pmax(flag[1, 2], as.numeric(c(DX[1, i] %in% valve))) flag[1, 3] = pmax(flag[1, 3], as.numeric(c(DX[1, i] %in% pulmcirc))) flag[1, 4] = pmax(flag[1, 4], as.numeric(c(DX[1, i] %in...
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 pmin and p...
2005 Apr 14
0
predict.glm(..., type="response") dropping names (and a propsed (PR#7792)
...0:03.000000000 -0500 +++ R-beta-fix/src/library/stats/R/family.R 2005-04-14 08:30:03.000000000 -0400 @@ -25,9 +25,9 @@ else if(!is.character(link) && !is.na(lambda <- as.numeric(link))) { linkfun <- function(mu) mu^lambda linkinv <- function(eta) - pmax(.Machine$double.eps, eta^(1/lambda)) + pmax(eta^(1/lambda), .Machine$double.eps) mu.eta <- function(eta) - pmax(.Machine$double.eps, (1/lambda) * eta^(1/lambda - 1)) + pmax((1/lambda) * eta^(1/lambda - 1), .Machine$double.eps) valideta <- fun...
2019 Jan 21
2
pmax and long vector
I see that base::pmax() does not support long vectors. Is R-devel interested in reports like this; ie. is there a goal of full support for long vectors in "basic" functions, something I at least would greatly appreciate? MRE: > pmax(rep(1L, 3*10^9), 0) Error in pmax(rep(1L, 3 * 10^9), 0) : long vector...
2005 Dec 20
0
pmin(), pmax() - slower than necessary for common cases
A 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...
2019 Jan 21
2
pmax and long vector
Kasper, If you're not interested or dont have time to create said patch yourself let me know and i can do it. Best, ~G On Mon, Jan 21, 2019, 11:36 AM Duncan Murdoch <murdoch.duncan at gmail.com wrote: > On 21/01/2019 12:35 p.m., Kasper Daniel Hansen wrote: > > I see that base::pmax() does not support long vectors. > > > > Is R-devel interested in reports like this; ie. is there a goal of full > > support for long vectors in "basic" functions, something I at least would > > greatly appreciate? > > > > MRE: > > > >> p...
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 # can't supply `na.rm=TRUE`...
2015 Dec 24
0
override pmin/pmax for my own matrix
Yes, functions like c, min and max are special cases, as they are primitives. For ordinary functions, you just need to promote them with "..." as the signature: setGeneric("pmax", signature="...") 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 intro...
2008 Jul 04
2
create a zero matrix & fill
...: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,pmin,...
2018 Jan 20
1
max and pmax of NA and NaN
Extremes.Rd, that documents 'max' and 'pmax', has this in "Details" section, in the paragraph before the last. By definition the min/max of a numeric vector containing an NaN is NaN, except that the min/max of any vector containing an NA is NA even if it also contains an NaN. ------------------ >>>>> Michal Burd...
2019 Jan 21
0
pmax and long vector
On 21/01/2019 12:35 p.m., Kasper Daniel Hansen wrote: > I see that base::pmax() does not support long vectors. > > Is R-devel interested in reports like this; ie. is there a goal of full > support for long vectors in "basic" functions, something I at least would > greatly appreciate? > > MRE: > >> pmax(rep(1L, 3*10^9), 0) > > Er...
2019 Jan 22
0
pmax and long vector
...nt have time to create said patch yourself > let me know and i can do it. > > Best, > ~G > > On Mon, Jan 21, 2019, 11:36 AM Duncan Murdoch <murdoch.duncan at gmail.com > wrote: > >> On 21/01/2019 12:35 p.m., Kasper Daniel Hansen wrote: >> > I see that base::pmax() does not support long vectors. >> > >> > Is R-devel interested in reports like this; ie. is there a goal of full >> > support for long vectors in "basic" functions, something I at least >> would >> > greatly appreciate? >> > >> &g...
2018 Jan 15
1
max and pmax of NA and NaN
Dear R users, is the following OK? > max(NA, NaN) [1] NA > max(NaN, NA) [1] NA > pmax(NaN, NA) [1] NA > pmax(NA, NaN) [1] NaN ...or is it a bug? Documentation says that NA has a higher priority over NaN. Best regards, Michal Burda [[alternative HTML version deleted]]
2015 Mar 25
2
[LLVMdev] Optimization puzzle...
...quot;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 uwtable "less-precise-fpmad"=&qu...
2007 Feb 19
6
Data frame: how to create list of row max?
Dear all, Can anyone please shed some light onto how to do this? This will give me all "intensity" columsn in my data frame: intensityindeces <- grep("^Intensity",names(dataframe),value=TRUE) This will give me the maximum intensity for the first row: intensityone <- max(dataframe[1,intensityindeces]) What I'm now looking for is how to dfo this for the whole data
2015 Mar 25
3
[LLVMdev] Optimization puzzle...
...uot; >> > 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 = { no...
2009 Sep 04
1
predicting from segmented regression
Hello I'm having trouble figuring out how to use the output of "segmented()" with a new set of predictor values. Using the example of the help file: ??set.seed(12) xx<-1:100 zz<-runif(100) yy<-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2) dati<-data.frame(x=xx,y=yy,z=zz) out.lm<-lm(y~x,data=dati) o<-## S3 method for class 'lm': segmented(out.lm,seg.Z=~x,psi=list(x=c(30,60)), control=seg.control(display=FALSE)) Now I would like t...
2012 Feb 09
1
Apply pmax to dataframe with different args based on dataframe factor
...different threshold value for # every track. # I tried something like this, but it's not working threshold <- list() threshold['A'] <- 0.2 threshold['B'] <- 0.4 threshold['C'] <- 0.5 for (track in levels(df$track)){ df[df$track==track,]$outcome <- pmax(df[df$track==track,]$outcome, threshold[track]) } # Warning messages: # 1: In is.na(mmm) : is.na() applied to non-(list or vector) of type 'NULL' # 2: In is.na(mmm) : is.na() applied to non-(list or vector) of type 'NULL' # 3: In is.na(mmm) :...
2004 Feb 02
3
mvrnorm problem
I am trying to simulate draws from a multivariate normal using mvrnorm, and am getting the following error message: Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) : non-conformable arrays I do not understand why I am getting this message, since the vector of means I am giving to the function is 13 by 1 and the variance matrix I am giving to the function is 13 by 13...these matrices are therefore conformable, right? Is it...