Displaying 20 results from an estimated 5000 matches similar to: "override pmin/pmax for my own matrix"
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
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
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
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 left
to people to discover on their own!
For example:
2008 Jul 04
2
create a zero matrix & fill
Dear R user,
I have written a function which returns max,min and variation of a power
(see below)
Power is a given matrix(1,n)
I call the function
>Variation<-VAR(p,(n-deltat))
Now the problem is when I want plot(Results[1],Results[2]). Not possible!
I become the following error (in english it means: Error in
as.double.default(x) :Object cannot be transformed in double)
>
2015 Mar 25
2
[LLVMdev] Optimization puzzle...
Hi everyone,
I am wondering what¹s stopping the LLVM optimizer (opt -O3) from
eliminating the apparently useless « icmp sgt » instruction in the
following piece of LLVM IR.
> ; ModuleID = 'lambda-opt.bc'
> target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-apple-macosx10.10.0"
>
> ; Function
2015 Mar 25
3
[LLVMdev] Optimization puzzle...
Here's a version that doesn't try to do block deletion on it's own. If you
use -adce then -simplifycfg, you get what you want.
It passes all tests except one, which is that we delete an invoke of a pure
function, IE Transforms/ADCE/dce_pure_invoke.ll -
I'm not sure why that's bad.
The reason we delete it is because it returns false to
I.mayHaveSideEffects(), and in particular,
2010 Mar 29
1
Suggestion: Adding quick rowMin and rowMax functions to base package
Hi,
I wonder whether similarly to the very quick rowSums and colSums
functions in the base package, one could 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
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]
2008 May 13
2
array dimension changes with assignment
Why does the assignment of a 3178x93 object to
another 3178x93 object 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
2011 Oct 04
1
a question about sort and BH
Hi,
I have two questions want to ask.
1. If I have a matrix like this, and I want to figure out the rows whose
value in the 3rd column are less than 0.05. How can I do it with R.
hsa-let-7a--MBTD1 0.528239197 2.41E-05
hsa-let-7a--APOBEC1 0.507869409 5.51E-05
hsa-let-7a--PAPOLA 0.470451884 0.000221774
hsa-let-7a--NF2 0.469280186 0.000231065
hsa-let-7a--SLC17A5
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 Burda <michal.burda at centrum.cz>
2008 Apr 27
1
parallel max, min, and median of dataframe columns
Hello, all,
I have a dataframe of three rows and umpteen columns. I want to show the
maximum, minimum, and median with a vertical line and a central dot (I'd
use a boxplot, but with only three data points, that's overkill; I can't
just use points, because of overlap and some of the other data plotted on
the graph).
This works:
> boxplot(data_frame,
2010 Sep 21
5
Combined plot: Scatter + density plot
Hi,
in order to save space for a publication, it would be nice to have a
combined scatter and density plot similar to what is shows on
http://addictedtor.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 <-
2003 Jul 10
1
The question is on Symmetry model for square table.
Please help,
I tried a program on S-plus, and it worked. Also I tried the same
program on R but not worked. Here is the programme. I put it in a
function form. The model and assumption are at the bottom.
where
counts<-c(22,2,2,0,5,7,14,0,0,2,36,0,0,1,17,10)
which is name.data, i is row size and j is the column size.
symmetry
function(i, j, name.data)
{
row <- (c(1:i))
col <-
2008 Aug 02
1
problem with nested loop for regression
Hi everyone,
I'm experiencing difficulty getting the results I want when I use a nested
for loop. I have a data set to which I perform some calculations, and then
try to apply a regression over a rolling window. The code runs, but the
regression results I am getting (intercept and slope) are simply the same,
repeated again and again in the results matrix. The regression does not seem
to be
2009 Feb 25
1
Unexpected side effect of the ":::" operator on the value of isGeneric
Hi,
when running the following on a fresh R,
library("IRanges")
annotation
showMethods("annotation")
Biobase:::annotation
showMethods("annotation")
I get (see the "^^^^^" marked output at the bottom):
> library("IRanges")
Carico il pacchetto richiesto: 'IRanges'
The following object(s) are masked from package:base :
2013 Jan 17
2
error installing KEGGSOAP
Hi, I am new to bioconductor, trying to install KEGGSOAP package, but got warnings() when installing and error message when trying to load the package, can anyone suggest what went wrong?
many thanks
John
> source("http://bioconductor.org/biocLite.R")
Bioconductor version 2.11 (BiocInstaller 1.8.3), ?biocLite for help
> biocLite("KEGGSOAP")
BioC_mirror:
2007 Sep 27
1
windows device transparency issue
I read in a thread in r-help today that the windows device in 2.6 supports
transparency, so I tried an example and had some issues. The density plots
should be filled with transparent color in the following example (similar to
the points), however the color is "fully" transparent. This works in the
Cairo device, but not in the windows device.
Thanks,
--Matt
Matt Austin
2008 Jun 24
2
L-BFGS-B needs finite values of 'fn'
Hi,
When I run the following code,
r <- c(3,4,4,3,5,4,5,9,8,11,12,13)
n <- rep(15,12)
x <- c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8)
x <- log10(x)
fr <- function(c, alpha, beta) {
P <- c + (1-c) * pnorm(alpha + beta * x)
P <- pmax(pmin(P,1),0)
-(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P)))
}
fit <- mle((fr), start = list(c