search for: testmat

Displaying 12 results from an estimated 12 matches for "testmat".

Did you mean: testdat
2005 Mar 29
2
strange error with rw2010dev
...I get a strange protect(): protection stack overflow error with a small data frame which otherwise is usable: If anybody wants to have a look I can provide an RData file with the problematic data frame. Doesn't seem to be necessary, the following simulated example generates the error: > testmat <- matrix(1:80, 20,4) > dim(testmat) [1] 20 4 > str(testmat) int [1:20, 1:4] 1 2 3 4 5 6 7 8 9 10 ... > testframe <- data.frame(testmat=I(testmat), x=rnorm(20), y=rnorm(20), z=sample(1:20)) > str(testframe) `data.frame': 20 obs. of 4 variables: $ testmat: int [1:...
2011 May 25
1
matrix Manipulation...
Hello everyone, I have a 2 x 5 matrix: say 0.2 0.3 1 -1 3 0.2. 0.4 5 0.5 -1 I want to replace all the values greater than or equal to 1 with 1 and those less than or equal to 0 with 0. So I should end up with a mtrix looking like: 0.2 0.3 1 0 1 0.2. 0.4 1 0.5 0 Any ideas how to do this? -- Thanks, Jim. [[alternative HTML version deleted]]
2010 Nov 18
1
dmultinomial
...) > dmultinomial(x=c(0,0,1),prob=c(1,1,1),size=1,log=TRUE) Error in if (ncol(x) != K) stop("x[] and prob[] must be equal length vectors or equal col matrix.") : argument is of length zero # Once I get the simple stuff above running, I'd like to be able to do the following: > testmat=rmultinomial(4, 1, prob) > testmat [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 0 1 [3,] 0 0 1 [4,] 0 0 1 > dmultinomial(x=testmat,prob=prob,size=1,log=TRUE) Error in if (!is.null(size) && nrow(size) != n) size <- matrix(t(size), : missing value wher...
2011 Dec 16
1
kmeans and plot labels
Hi, Thanks Sarah. Unfortunately I did not get a step further. My question, perhaps a bit clearer, is how to display the case control status (or any other arbitrary point label) after clustering in a plot: With a bit of pseudo code, where dataset is a data.frame, parameters are those column names where we find numerical values (no NAs) and nclasses is the desired number of classes. fit <-
2010 Oct 22
3
Conditional looping over a set of variables in R
Here's the problem I'm trying to solve in R: I have a data frame that consists of about 1500 cases (rows) of data from kids who took a test of listening comprehension. The columns are their scores (1 = correct, 0 = incorrect, . = missing) on 140 test items. The items are numbered sequentially and are ordered by increasing difficulty as you go from left to right across the columns. I want
2017 Jan 27
0
Matrix package breaks as.matrix method
...t; (e.g. with package.skeleton) with one file in mat/R/mat.R with the following contents: setClass("mat", representation(H="matrix")) mat <- function(H) new("mat", H=H) setMethod("as.matrix", signature("mat"), function(x, ...) crossprod(x at H)) testmat <- function() { H <- matrix(1:3, 1, 3) M <- mat(H) as.matrix(M) } Then install the mat package : > require(mat) > testmat() [,1] [,2] [,3] [1,] 1 2 3 [2,] 2 4 6 [3,] 3 6 9 All works fine! Now add "Depends: Matrix" into the pack...
2007 Feb 16
0
re : array searches
Hi, I am not sure to get the issue, but assuming your data are arranged as in your example with dates in column x$V1 and signals as x$V2 , I think that you could use "rle" in the following way : test<-rle(x$V2) testmat<-matrix(NA,length(test$values),2) testmat[,1]<-x[c(1,cumsum(test$length)[1:(length(test$values)-1)]+1),1] testmat[,2]<-test$values And you'll get your result without the duplicates, arranged as follow : [,1] [,2] [1,] "31/01/2007" "-1" [2,] "03/02...
2017 Jan 30
0
Matrix package breaks as.matrix method
Georgi, Brilliant, thank you very much for the helpful reply and explanation! I added 'importFrom("Matrix","as.matrix")' to my NAMESPACE and all worked fine! As my 'as.matrix' method is used entirely internally to the 'testmat' function (and not "used outside the package"), I don't think I actually need to export it. In my case, testmat is defined inside the package, and not in the global workspace (nothing is defined in the global workspace in my example). To your point that I should just "impor...
2010 Dec 13
7
descriptive statistics
Hi. In a data set I have a variable that takes values from 1 to 14. For each subgroup of values of this variable, I would like to obtain some descriptive statistics of other variables present in the data set. I've been trying with a "for" loop but I couldn't get nothing. Could you please suggest me some lines? -- View this message in context:
2017 Jan 29
0
R-devel Digest, Vol 167, Issue 25
...t; (e.g. with package.skeleton) with one file in mat/R/mat.R with the following contents: setClass("mat", representation(H="matrix")) mat <- function(H) new("mat", H=H) setMethod("as.matrix", signature("mat"), function(x, ...) crossprod(x at H)) testmat <- function() { H <- matrix(1:3, 1, 3) M <- mat(H) as.matrix(M) } Then install the mat package : > require(mat) > testmat() [,1] [,2] [,3] [1,] 1 2 3 [2,] 2 4 6 [3,] 3 6 9 All works fine! Now add "Depends: Matrix" into the pack...
2008 Apr 22
2
nth step transition matrices
Hello, I have a question in regards to markov chains and transition probabilities. I am trying to figure out a way to calculate the "kth-step transition matrix" of a given matrix. Say for example I have a single step 2x2 matrix: 1 2 P= 1 .95 .05 2 .01. 99 If I were to convert this matrix to a 2-step transition probability matrix I would get:
2011 Sep 30
1
Covariance-Variance Matrix and For Loops
Hello, I am very new to R (as my Subject probably indicates). I want to do something that should, I think, be very simple. I have five vectors in a list and I want to construct a covariance matrix out of them. Given a 5X5 matrix cvm1, and the list of vectors, cvm1_list, I thought the following would work (sorry cannot find code tags): for(i in 1:5){ for(j in 1:5){ cvm1[i,j] <-