Displaying 6 results from an estimated 6 matches for "colprods".
Did you mean:
colpos
2010 Aug 15
3
Rows index/colProds
Hi,
Is there any function to replace colProds that finds column-wise products of
a matrix?
Or is there any other function that would give a better solution this
problem ?
I have a matrix and an array, example:
> a
GSM1.CEL GSM2.CEL GSM1.CEL
10000_at 1 3 1
10001_at...
2013 Sep 02
3
Product of certain rows in a matrix
Hi,
You could try:
A<- matrix(unlist(read.table(text="
1 2 3
4 5 6
7 8 9
9 8 7
6 5 4
3 2 1
",sep="",header=FALSE)),ncol=3,byrow=FALSE,dimnames=NULL)
library(matrixStats)
?res1<-t(sapply(split(as.data.frame(A),as.numeric(gl(nrow(A),2,6))),colProds))
?res1
#? [,1] [,2] [,3]
#1??? 4?? 10?? 18
#2?? 63?? 64?? 63
#3?? 18?? 10??? 4
?res2<-t(sapply(split(as.data.frame(A),((seq_len(nrow(A))-1)%/%2)+1),colProds))
?identical(res1,res2)
#[1] TRUE
#or
?t(sapply(split(as.data.frame(A),as.numeric(gl(nrow(A),2,6))),function(x) apply(x,2,prod)))
#or...
2013 Sep 04
2
Random products of rows in a matrix
Hello everybody,
Without any loop and any package,
I would like to return N products of M rows in a matrix A :
Today, I managed to do it with a loop :
B <- matrix(NA, ncol = ncol(A), nrow = 0)
for (i in 1 : N) B <- rbind(B, apply(A[sample(1 : nrow(A), M, replace = T),
], 2, prod))
Do you have a solution ?
Thank you in advance !
[[alternative HTML version deleted]]
2009 Nov 10
1
What is the equivalent of column.prods() from S in R?
Chambers' book Statistical Models in S mentioned 'column.prods()'. But
I don't find it in R. I'm wondering if there is an equivalent in R?
2012 Apr 19
4
Column(row)wise minimum and maximum
Hi,
Currently, the "base" has colSums, colMeans. It seems that it would be useful to extend this to also include colMin, colMax (of course, rowMin and rowMax, as well) in order to facilitate faster computations for large vectors (compared to using apply). Has this been considered before? Please forgive me if this has already been discussed before.
Thanks,
Ravi
Ravi Varadhan, Ph.D.
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