search for: matrix

Displaying 20 results from an estimated 20331 matches for "matrix".

2008 Dec 27
0
Sonic Mega Collection crashes on startup.
...id timer ID warn:mmtime:timeKillEvent wID=3 is not a valid timer ID warn:d3d:state_rangefog_w Range fog enabled, but not supported by this opengl implementation warn:d3d:state_blendop Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT warn:d3d:transform_worldex Unsupported blend matrix set warn:d3d:transform_worldex Unsupported blend matrix set warn:d3d:transform_worldex Unsupported blend matrix set warn:d3d:transform_worldex Unsupported blend matrix set warn:d3d:transform_worldex Unsupported blend matrix set warn:d3d:transform_worldex Unsupported blend matrix set warn:d3d:transf...
2009 Jul 20
3
Write in file matrices of sifferent size
Hi list, How to save a list content into a text file? Please consider example below, I have two numeric matrices that I bundle into a list & give each list element a name Example: > matrixA <- matrix(0,5,4) > matrixB <- matrix(1,7,13) > matrixList <- list(matrixA,matrixB) > names <- c("Matrix A","Matrix B") > names <- names(matrixList) How could I get the list in a txt as below: " Matrix A (Matrix A element 1,1), (Matrix A...
2007 Dec 04
1
Metropolis-Hastings within Gibbs coding error
...dex <- 1:Nsim # creating index a0 <- 10 # initial value (assumed) for tau b0 <- (.01) # initial value (assumed) for tau fit <- glm((y/n)~x,family=binomial, weight = n, data=dta) # initial value for beta parameters <- c("Beta0", "Beta1", "Tau") parameter.matrix <- array(NA,c(Nsim,3)) # blank array parameter.matrix <- as.data.frame(parameter.matrix) # creating data frame parameter.matrix[1,] <- c(fit$coef[1],fit$coef[2],rgamma(1, shape=a0, scale = b0)) # putting initial values for (i in 2:Nsim){ # generating Gibbs sampler parameter.matrix[i,]&lt...
2006 Jul 27
2
Vector extracted from a matrix. How can I specify dimensions in as.matrix?
Transpose vector extracted from a matrix Hello, I am doing a recursive analysis that uses every line (vector) of a matrix in a loop. In the model, I need to transpose those vectors that are extracted from a matrix. Using simple vectors (no matrix involved) the transpose function works fine: simplevector <-matrix(1:3,3,1) tsimplev...
2006 Apr 07
3
strange matrix behaviour: is there a matrix with one row?
Consider this: > y <- matrix(1:8, ncol=2) > is.matrix(y[-c(1,2),]) [1] TRUE > is.matrix(y[-c(1,2,3),]) [1] FALSE > is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again I just s...
2010 Apr 21
1
Cross-checking a custom function for separability indices
...various Separability Measures # by Nikos Alexandris, Freiburg, 8.04.2010 # ( based on Divergence and Jeffries-Matusita, requires input variables "as.matrices" ) separability.measures <- function ( Vector.1 , Vector.2 ) { # convert vectors to matrices in case they are not Matrix.1 <- as.matrix (Vector.1) Matrix.2 <- as.matrix (Vector.2) # define means mean.Matrix.1 <- mean ( Matrix.1 ) mean.Matrix.2 <- mean ( Matrix.2 ) # define difference of means mean.difference <- mean.Matrix.1 - mean.Matrix.2 # define covariances for sup...
2001 May 29
2
Apply command on vectors
Hi all, I keep running into a small problem in my programming, and I'm sure there's an elegant way around it... I often want to use apply() on a matrix with a variable number of columns. It works just fine unless the number of columns is one, in which case the matrix becomes a vector, and apply() complains. Example below: ----------------------------- a.matrix <- matrix(rnorm(6), nc=3) matrix.mask <- c(1,2) apply(a.matrix[,matrix.mask],...
2012 Nov 30
1
Baffled with as.matrix
I'm puzzled by as.matrix. It appears to work differently for Surv objects. Here is a session from my computer: tmt% R --vanilla > library(survival) Loading required package: splines > ytest <- Surv(1:3, c(1,0,1)) > is.matrix(ytest) >[1] TRUE > attr(ytest, 'type') [1] "right" &gt...
2013 Jan 25
3
Removal of columns from matrix where all values of the column are identical.
Hi all, I'd like to write a piece of code which will remove columns from a matrix, if the column contains only one value, say every value in the column is a "3": Matrix <- matrix(NA, nrow=5, ncol=4) Matrix[,1] <- c(1,2,3,4,5) Matrix[,2] <- c(3,3,3,3,3) Matrix[,3] <- c(5,4,3,2,1) Matrix[,4] <- c(5,1,4,3,2) [,1] [,2] [,3] [,4] [1,] 1 3 5...
2005 Feb 21
1
is.matrix(), as.matrix, & as(,"matrix")
Under help(matrix) it is written: 'is.matrix' tests if its argument is a (strict) matrix. It is generic: you can write methods to handle specific classes of objects, see InternalMethods. Further down, under "Details", the meaning of "strict" is explained more explicitl...
2008 Jun 11
4
Matrix transformation problem
ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y). Sometimes, the matrix is quite large, so I have a perfoma...
2012 Sep 11
1
lapply with different size lists?
Hello, I have 2 functions (a and b) a = function(n) { matrix (runif(n*2,0.0,1), n) } > > > b = function (m, matrix) { > n=nrow (matrix) > p=ceiling (n/m) > lapply (1:p, function (l,n,m) { > inf = ((l-1)*m)+1 > if (l<p) sup=((l-1)*m)+m >...
2006 Dec 05
4
incidence and adjacency matrix conversion
Dear all, how can I convert an m x n incidence matrix into an m x m adjacency matrix or an n x n adjacency matrix? The current matrix contains binary data, hence the new matrix would contain counts of common occurrences. Thank you for your help. Phil
2007 Dec 14
1
Result depends on previous result; easy with a loop; but without a loop?
...ng" for the wrong terms. If I remember correctly, I think I even asked this question a few years ago. But I cannot even find this. The basic problem is that a result depends on a previous result. This is easy with a loop--but how can I do this without a loop? Lets give an example: initial.matrix <- rbind(rep(1,4), matrix(0,ncol=4,nrow=5)) the.other.matrix <- matrix(runif(20), ncol=4, nrow=5) the initial matrix should be filled according to the following (pseudo-code) rule: if (row==1) initial.matrix[1,] <- 1 if (row>1) initial.matrix[x,] <- initial.matrix[x-1,] * the.othe...
2006 Mar 01
3
matrix matching NA
Dear R list members, I am seeking for an elegant way for matching NA elements of a matrix. Everthing I tried, the result was a vector. Here ist an example with vectors that works: a and b are vectors of same lenght representing pairs of data (a[i] b[i]) with some NA elements: ## R Code a <- (1:5) a[2] <- NA b <- (6:10) b[3] <- NA a 1 NA 3 4 5 b 6 7 NA 9 1...
2016 Oct 03
2
suggested addition to model.matrix
Hello, All: What's the simplest way to convert a data.frame into a model.matrix? One way is given by the following example, modified from the examples in help(model.matrix): dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) ab <- model.matrix(~ a + b, dd) ab0 <- model.matrix(~., dd) all.equal(ab, ab0) What do you think about replacing "model.matr...
2007 Jan 26
2
%*% in Matrix objects
Dear R users, I need to normalize a bunch of row vectors. At a certain point I need to divide a matrix by a vector of norms. I find that the behavior of Matrix objects differs from normal matrix objects. Example the following code examples differ only in xnormed changing from normal to Matrix object: x = matrix(1:12,3,4) x = as(x, "CsparseMatrix") xnorms = sqrt(colSums(x^2)) (xnormed...
2012 Dec 08
5
How to efficiently compare each row in a matrix with each row in another matrix?
...o matrices A and B. They have the same number of columns but possibly different number of rows. I would like to compare each row of A with each row of B and check whether all entries in a row of A are less than or equal to all entries in a row of B. Here is a minimal working example: A <- rbind(matrix(1:4, ncol=2, byrow=TRUE), c(6, 2)) # (3, 2) matrix B <- matrix(1:10, ncol=2) # (5, 2) matrix ( ind <- apply(B, 1, function(b) apply(A, 1, function(a) all(a <= b))) ) # (3, 5) = (nrow(A), nrow(B)) matrix The question is: How can this be implemented more efficiently in R, that is, in a fast...
2005 Apr 18
2
Construction of a large sparse matrix
Dear List: I'm working to construct a very large sparse matrix and have found relief using the SparseM package. I have encountered an issue that is confusing to me and wonder if anyone may be able to suggest a smarter solution. The matrix I'm creating is a covariance matrix for a larger research problem that is subsequently used in a simulation. Below is t...
2018 Apr 23
4
R 3.5.0 fails its regression test suite on Linux/x86_64
...running code in 'eval-etc.R' ... OK | comparing 'eval-etc.Rout' to './eval-etc.Rout.save' ...414,416c414,548 | < Warning message: | < In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : | < there is no package called 'Matrix' | --- | > Trying some Matrix objects, too | > | > Matrix> Matrix(0, 3, 2) # 3 by 2 matrix of zeros -> sparse | > 3 x 2 sparse Matrix of class "dgCMatrix" | > | > [1,] . . | > [2,] . . | > [3,] . . | > | > Matrix> Matrix(0,...