search for: tmat

Displaying 20 results from an estimated 25 matches for "tmat".

Did you mean: that
2006 Jul 06
3
Comparing two matrices [Broadcast]
It might be a bit faster to do matrix indexing: R> tbm <- as.matrix(tb) # turn it into a character matrix R> tmat[cbind(match(tbm[,2], rownames(tmat)), match(tbm[,1], colnames(tmat)))] <- 1 > tmat Apple Orange Mango Grape Star A 1 1 1 0 0 O 1 1 0 0 0 M 0 0 1 0 0 G 0 0 0 0 0 S 1 1 1 0 0 HTH, Andy From...
2006 Jul 06
3
Comparing two matrices
hi: I have matrix with dimensions(200 X 20,000). I have another file, a tab-delim file where first column variables are row names and second column variables are column names. For instance: > tmat Apple Orange Mango Grape Star A 0 0 0 0 0 O 0 0 0 0 0 M 0 0 0 0 0 G 0 0 0 0 0 S 0 0 0 0 0 > tb # tab- delim file. V1 V2 1 Apple S 2 Apple A 3 Apple O 4 Orange A 5 Orange O 6 Or...
2005 Apr 15
4
function corresponding to map of perl
Is there a function in R that corresponds to the function ``map'' of perl? It could be called like: vector.a <- map( vector.b, FUN, args.for.FUN ) It should execute for each element ele.b of vector.b: FUN( vector.b, args.for.FUN) It should return a vector (or data.frame) of the results of the calls of FUN. It nearly works using: apply( data.frame( vector.b ), 1, FUN,
2010 Dec 02
1
Arrange elements on a matrix according to rowSums + short 'apply' Q
...ft, in descending order. Does this make sense? In this case the order I'm looking for would be B, D, A, E, C Any thoughts? As an aside, here is the function I've written to construct the transition matrix. Is there a more elegant way to do this that doesn't involve a double transpose? TMAT <- apply(t(MAT), 2, function(X) X/sum(X)) TMAT <- t(TMAT) I tried the following: TMAT <- apply(MAT, 1, function(X) X/sum(X)) But my the custom function is still getting applied over the columns of the array, rather than the rows. For a check try: rowSums(TMAT) colSums(TMAT) Row sums h...
2002 Mar 18
2
persp(): add second plane (second, long question)
...would fit the box (x and y values are the same for both (1x6vectors)). And I'm able to store the z-values in two different matrices (6x6). What I did then is > xachse<-c(1:6) > yachse<-xachse > > par(bg = "white") > > trans3d <- function(x,y,z,pmat) { + tmat <- t((cbind(x,y,z,1)%*% pmat)) + list(x=tmat[1,]/tmat[4,],y=tmat[2,]/tmat[4,]) + } > pmat <- persp(xachse, yachse, betaon1.median.plot,zlim=c(2.75,3.30), theta = 60, phi = 20, + col = "lightblue", xlab = "X", ylab = "Y", zlab = "Z", +...
2006 Mar 25
2
pairwise combinatons of variables
...onally: For anybody who is willing to offer some advise, here is my complete approach: library(e1071) mat <- matrix( c(6,7,8,2,3,4,12,14,14, 14,15,13,3,1,2,3,4,2, 15,3,10,5,11,7,13,6,1, 15,4,10,6,12,8,12,7,1), ncol=9, byrow=T ) rownames(mat) <- paste("v", 1:4, sep="" ) tmat <- t(mat) cluster <- c(1, 2, 1, 3, 3, 3, 1, 2, 2) centroids <- matrix( 0, ncol=3, nrow=4 ) obj <- vector(mode="list", length=3) for (j in 1:4){ for (i in 1:3){ where <- which(cluster==i) # which obj is in which class? centroids[j,i] <- mean( tmat[ where,j ] ) obj[...
2002 Aug 01
4
What does persp() return?
I want to plot some 3D points on top of the grid produced by persp(). On 2/22/01, Paul Murrell <paul at stat.auckland.ac.nz> wrote in R-help: > In S-Plus, persp() returns a value that can be used to transform 3D > locations to 2D, but this sort of thing is not (yet) available in R. But persp() does return something (in R-1.5.1): a 4x4 matrix which in the C code is called the
2006 Mar 23
0
kmeans Clustering
...le variable pairs and apply kmeans again, which is quite confusing to me. Here is what I do: ## 0. data mat <- matrix( c(6,7,8,2,3,4,12,14,14, 14,15,13,3,1,2,3,4,2, 15,3,10,5,11,7,13,6,1, 15,4,10,6,12,8,12,7,1), ncol=9, byrow=T ) rownames(mat) <- paste("v", 1:4, sep="" ) tmat <- t(mat) ## 1. Provide clusters via Ward: ward <- hclust(d=dist(tmat), method = "ward", members=NULL) ## 2. Compute cluster centers and create center-matrix for kmeans: groups <- cutree(ward, k = 3, h = NULL) centroids <- vector(mode="numeric", length=3) obj &lt...
2002 Oct 21
2
3-D scatter plot laid over Surface plot
Hello, I have created a Fitness surface (persp()), with data that was created by a tp spline procedure. Now I would like to superimpose a set (XYZ) of existing points (from two different treatments) onto this surface. I didn't come across any function or command that is able to do this in R. Could somebody please help me in finding a solution to this problem Thank you Peter --
2002 Mar 14
1
persp(): add second plane
Dear R-users, is it possible to add a second plane to the persp()-plot? I couldn't find any hint on that in the news archive... I'm using R.1.4.1 for Windows. Thanks in advance, Nina -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or
2002 Mar 14
1
persp(): add second plane
Dear R-users, is it possible to add a second plane to the persp()-plot? I couldn't find any hint on that in the news archive... I'm using R.1.4.1 for Windows. Thanks in advance, Nina -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or
2011 Sep 17
0
Warning in 'probtrans'-function ('mstate'-package)
...n is: How does this "inconsistency"(?) arise and are there any criterias to decide whether the model's validity is seriously affected of it? Best, Johannes ### EXAMPLE: # library(mstate) # set up transistion matrix for illness-death model with competing risks (2 death causes) tmat <- transMat(x=list( c(2), c(3,4), c(), c()), names= c(NA, "ill", "cause1", "cause2")) # create example data with 't' (time), 's' (status) & 'v' (variables/predictors) in 'wide format'.. set.seed(123) S1 <- data.frame( t1 = r...
2000 Aug 29
4
short way
i want to replace certain values of a matrix. i know how to replace them when the values are in a vector. i tried the same way for a matrix and got this answer: la[la==0]<-1 Error in [<-.data.frame(*tmp*, la == 0, value = 1) : matrix subscripts not allowed in replacement i found a way to do this with "for()", but i think this is the worst way to do it. So is there a
2010 Oct 07
1
model.frame deficiency
The model.frame function has trouble with a certain type of really long formula. Here is a test: tname <- paste('var', 1:50, sep='') tmat <- matrix(rnorm(500), ncol=50, dimnames=list(NULL, tname)) tdata <- data.frame(tmat) temp1 <- paste( paste(tname, tname, sep='='), collapse=', ') temp2 <- paste("~1 + cbind(", temp1, ")") model.frame(as.formula(temp2), tdata) This came out of a use...
2007 Jul 03
1
loop causes syntax error in print()
...on of the table. ...[multiple loops and calculations ending with.....]... + print(paste(mutType,"sim",sim,"hmm",hmm)) + # print(acctab[,10:15]) + + nummod <- nummod +1 + } #end hmmMats loop + } #end tmats loop + } #end mut type loop [1] "dup sim Imod hmm Jmod" > print(acctab[,10:15]) hitrate falsepos multrate avghit avgmiss avgfalsepos 1 0.0000000 1 NaN NaN 2 NA 2 1.0000000 0 0.00000000 5.333333 NaN NA...
2002 Nov 19
5
plotting intersecting planes
Hi all In two days, I am giving a small, informal workshop in our Department about using R. Initially, it was just for statistician, but surprisingly (to me anyhow) many mathematicians are also coming who have a MATLAB background. They are coming at the Workshop from a teaching perspective. They are considering using R to avoid licensing issues with MATLAB. One thing they were hoping me to
2001 Jul 17
2
cmdscale in package mva (PR#1027)
...an unexplicable way (for me). The following lines show what happened. I tried the very same on linux, and it worked fine. >a <- matrix(c(1,2,3,2),3,3) >a [,1] [,2] [,3] [1,] 1 2 3 [2,] 2 1 2 [3,] 3 2 1 >library(mva) >cmdscale(a) Error in La.eigen(Tmat, symmetric = TRUE) : On entry to DSYEV parameter number 8 had an illegal value Regards, Laurent PS: I had trouble during the 'make check' installation step. I was pointed out it was a known problem with modreg on SGIs. I think both things are independant, but, well, one never kn...
2017 Jun 04
0
New var
...s", "start", "end", "D", "bin"), row.names = c(NA, -6L), class = "data.frame") Construct a matrix of the six alternatives: tvals <- c(1, -1, -1, -1, -1, 0, 1, -1, -1, -1, 0, 0, 1, -1, -1, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0) tmat <- matrix(tvals, 6, 5, byrow=TRUE) colnames(tmat) <- paste0("t", 1:5) tmat # t1 t2 t3 t4 t5 # [1,] 1 -1 -1 -1 -1 # [2,] 0 1 -1 -1 -1 # [3,] 0 0 1 -1 -1 # [4,] 0 0 0 1 -1 # [5,] 0 0 0 0 1 # [6,] 0 0 0 0 0 idx <-as.numeric(DFM$bin) (DFM <- data.frame(DF...
2002 Jan 10
1
Size of type double in object type dist (PR#1255)
The following problem occurs in R 1.4.0 and 1.3.1 for Windows95, but not in R 1.2.0 for Windows95. The problem does not occur in R 1.4.0 for Linux PC, Linux Alpha and HP-UX. Sometimes, the type of 'Size' of an object of type 'dist' changes from integer into double. Running cmdscale on such a 'dist' object gives invalid results. I don't know what should be considered
2017 Jun 04
2
New var
Thank you Jeff and All, Within a given time period (say 700 days, from the start day), I am expecting measurements taken at each time interval;. In this case "0" means measurement taken, "1" not taken (stopped or opted out and " -1" don't consider that time period for that individual. This will be compared with the actual measurements taken (Observed-