Displaying 8 results from an estimated 8 matches for "smat".
Did you mean:
smart
2007 Jun 23
1
Creating different matrices in a loop
Hello,
I have a big matrix of size (20,5) -bmat . I have to loop though the rows in
the matrix and create DIFFERENT matrices each time I go through the loop.
counts=c(4,6,10);
p=1;
for (i in 1:length(counts))
{
smat=bmat[p:p+i-1,];
p=p+i;
}
The problem is smat overwrites itself each time inside the loop. I would
like to have smat1, smat2, smat3 instead of a single vector smat. Basically
I wanted to change the name of the matrix "smat" each time the loop runs so
that i will have 3 different matri...
2011 Nov 21
1
Sub sets
...on list for the archives. That said, I
think this function does what you were hoping for.
Michael
powerset <- function(n, items = NULL){
if(!is.null(items)) {
if(n != length(items)) warning("Resetting n in preference to
length(items)")
n = length(items)
}
smat <- do.call(expand.grid, rep(list(c(0,1)), n))
if(!is.null(items))
smat <- smat * matrix(items, ncol = n, nrow = 2^n, byrow = T)
smat
}
On Sat, Nov 19, 2011 at 8:49 PM, Gyanendra Pokharel
<gyanendra.pokharel at gmail.com> wrote:
> Hi Michael,
> I have trouble to f...
2005 Oct 25
1
Small issue with R's C API
Consider the R code:
mat <- matrix(seq(1,20),4,5)
is.matrix(mat) # gives TRUE
is.vector(mat) # gives FALSE
On the other hand, if mat is passed through the .Call interface the
corresponding SEXP (call it smat) satisfies
isMatrix(smat) // TRUE
isVector(smat) // TRUE
Consequently, you cannot distinguish matrices from vectors. Looking
at the dim attribute of a vector doesn't help because this is garbage.
Dominick
2005 Apr 18
2
Very Slow Gower Similarity Function
...em.
The function is:
### Gower Similarity Matrix###
sGow <- function (mat){
OBJ <- nrow(mat) #number of objects
MATDESC <- ncol (mat) #number of descriptors
MRANGE <- apply (mat,2,max, na.rm=T)-apply (mat,2,min,na.rm=T) #descr ranges
DESCRIPT <- 1:MATDESC #descriptor index vector
smat <- matrix(1, nrow = OBJ, ncol = OBJ) #'empty' similarity matrix
for (i in 1:OBJ){
for (j in i:OBJ){
##calculate index vector of non-NA descriptors between objects i and j
descvect <- intersect (setdiff (DESCRIPT, DESCRIPT[is.na(mat[i,DESCRIPT])]),
setdiff (DESCRIPT, D...
2011 Sep 03
2
problem in applying function in data subset (with a level) - using plyr or other alternative are also welcome
Dear R experts.
I might be missing something obvious. I have been trying to fix this problem
for some weeks. Please help.
#data
ped <- c(rep(1, 4), rep(2, 3), rep(3, 3))
y <- rnorm(10, 8, 2)
# variable set 1
M1a <- sample (c(1, 2,3), 10, replace= T)
M1b <- sample (c(1, 2,3), 10, replace= T)
M1aP1 <- sample (c(1, 2,3), 10, replace= T)
M1bP2 <- sample (c(1, 2,3), 10, replace= T)
2010 Sep 29
1
location of Rconfig.h when using architecture-dependent subdirs
Hello,
I just tried configuring R to use architecture-dependent subdirs
$ r_arch=x86_64 ./configure --prefix=/u/smat/konis/testdir
on a Debain Squeeze box
$ uname -a
Linux smapc007 2.6.32-5-686 #1 SMP Sat Sep 18 02:14:45 UTC 2010 i686
GNU/Linux
After building and installing, the Rconfig.h ended up in
.../lib/R/include/x86_64 but R.h still includes it as
#include <Rconfig.h>
I noticed that the C...
2011 Jun 26
2
Ordering a matrix based on cluster no
Hi All
I have a symmetric matrix of genes ( 100x100 matrix). I also have a matrix
(100x2) of two columns where column 1 has the gene names and column 2 has
the cluster it belongs to (they are sorted and grouped based on the cluster
no).
I would like to order the rows and columns of the 100x 100 matrix such that
the first n genes correspond to cluster 1 and next n genes correspond to
cluster 2
2010 Mar 11
4
help about solving two equations
I have two matrix s1 and s2, each of them is 1000*1.
and I have two equations:
digamma(p)-digamma(p+q)=s1,
digamma(q)-digamma(p+q)=s2,
and I want to sovle these two equations to get the value of x and y, which are also two 1000*1 matrices.
I write a program like this:
f <- function(x) {
p<- x[1]; q <- x[2];
((digamma(p)-digamma(p+q)-s1[2,]) )^2 +((digamma(q)-digamma(p+q)-s2[2,]) )^2