search for: testmatrix

Displaying 6 results from an estimated 6 matches for "testmatrix".

2007 Jul 31
2
remove NA rows and columns
Hello, I guess, it's a rather simple thing but I cannot find a short way to reduce a matrix, removing all rows and columns having just NA elements. testmatrix <- matrix(nrow=6, ncol=4) testmatrix[2:5,2:3] <- seq(2) > testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA 1 1 NA [3,] NA 2 2 NA [4,] NA 1 1 NA [5,] NA 2 2 NA [6,] NA NA NA NA the new matrix should look like this (by t...
2011 May 27
1
eigenvalues and correlation matrices
...this matrix are: 1,2 and 4. I have confirmed this using the following site: http://www.akiti.ca/Eig3Solv.html However, when I run my code in R (see below), I get different answers. What gives? #test std 3 x 3: setwd("S:/790/Actuarial/Computing and VBA/R development/ Eigenvalues") testmatrix<-data.frame(read.csv("threeBythree.csv",header=FALSE)) testmatrix #check that the matrix drawn in is correct nrow(testmatrix) ncol(testmatrix) #calculate the eigenvalues eigen(testmatrix,symmetric = TRUE,only.value=TRUE)
2010 Feb 08
1
Help with assigning values to a row or column
...value to a row or column within the matrix that it runs on. I am, however, having trouble accessing the row or column within this dynamic variable. I have looked through the archives (nothing there) and read the rules for posting to this list. Please help me out! Here is a sample of the problem: testMatrix = matrix(data=2, nrow=10, ncol=10) testFunction = function (input) { inputName <<- deparse(substitute(input)) assign(inputName[1,], 4, envir = .GlobalEnv) } #this will give you the error testFunction(testMatrix) When I try to access "inputName[1,]" instead of "inpu...
2008 Apr 03
1
by "infelicity"
...r list, Please find below an example of odd behaviour of the by function. It occurs both under GNU/Linux R 2.6.2 and Windows R 2.7.0alpha. Respective sessionInfo()'s are given below. I hope I do not overlook anything. testFactor <- factor(sample(LETTERS[1:6], size = 42, replace = TRUE)) testMatrix <- matrix(rnorm(42 * 6), nrow = 42) testDf <- as.data.frame(testMatrix) by(data = testDf, INDICES = testFactor, FUN = mean) # OK by(data = testDf, INDICES = testFactor, FUN = median) # error # Error in median.default(data[x, ], ...) : need numeric data Kind regards, Tobias ### GNU/Linux ##...
2008 Nov 04
1
contour plot, failing to interpolate through all data
...the dataset, and I get the same problem when using the full data. The only reason I get any contours is because I'm forcing specific levels. If no levels are declared, no contours are generated. Please excuse my hack job at coding. thanks in advance! Michael ####start data to be in file='testmatrix.csv' "0.5","1","1.5","2","2.5","3" "-0.833",NA,NA,NA,NA,NA,21.05 "-0.8",NA,NA,NA,NA,10.62,NA "-0.75",NA,NA,NA,5.13,NA,NA "-0.667",NA,NA,2.24,NA,NA,11.68 "-0.6",NA,NA,NA,NA,5.69,NA &quo...
2007 Feb 06
3
How-To construct a cov list to use a covariance matrix in factanal?
Hi, I have a set of covariance matrices but not the original data. I want to carry out some exploratory factor analysis. So, I am trying to construct a covariance matrix list as the input for factanal. I can construct a list which includes the cov, the centers, and the n.obs. But it doesn't work. I get an error that says "Error in sqrt(diag(cv)) : Non-numeric argument to mathematical