search for: newmat

Displaying 20 results from an estimated 34 matches for "newmat".

Did you mean: newman
2012 Oct 26
1
Creating a correlation matrix from a vector
I'm looking to create a correlation matrix, but I have already obtained the correlations, which are stored in a vector. (Basically, I'm running a simulation which requires a correlation matrix, but I am simulating the various correlations.) My aim is to create a function that can take the vector, and fit the values into their respective locations in a correlation matrix. (The correlations
2005 May 05
2
efficient filtering of matrices
...as wondering if someone can tell me the best way to search through a matrix and choose certain rows (based on certain conditions) to put into a separate matrix. What I have tried so far is very slow for a large dataset I'm working with. e.g., I have this piece of code to create a new matrix (newmat) based on my filtering conditions. Do I need to do this kind of thing where I keep rbinding? newmat<-rep(NA,12) for (i in 1:length(origmat[,1]) { if ( is.na(origmat[i,10]) | (!is.na(origmat[i,10]) & (origmat[i,2] <= origmat[i,10]) ) ) newmat<-rbind(newmat, origmat[i,]) }...
2001 Oct 09
3
Unlisting while preserving object types?
Hi A toy example is probably the least ambiguous way of explaining what I'm trying to do. > library(ts) > zz<-list(a=rnorm(100),b=rt(100,3)) > zz.spec<-lapply(zz,spectrum,plot=F) > summary(zz.spec) Length Class Mode a 15 spec list b 15 spec list I'm looking for an elegant way to fetch components of the sub-lists a and b of zz.spec; e.g. to make a matrix
2005 Aug 31
5
"best" c++ matrix library?
Hi folks, I am planning to write some more time-consuming matrix manipulations in c++. What is the experience with the existing c++ matrix libraries? Do you have some recommendations? Are some libraries more compatible with R than the others? All suggestions welcome! Best, Ott
2007 Oct 16
1
error in sample ()
I am trying to get a random matrix based on an original matrix called disperser.mx, with dimensions 30x73 When I write the following code: >scramble = sample (disperser.mx) >newmat = matrix(scramble, nrow=30) I get the following warning message and a very weird matrix with 30 rows but only 3 columns shown below: Warning message: data length [73] is not a sub-multiple or multiple of the number of rows [30] in matrix in: matrix(scramble, nrow = 30) [,1] [,2]...
2010 Mar 26
2
Odd results with %% and conserving memory
...actually 1. Can someone explain this? If you pick just a single number you can see some odd results too. > (4.1*100)%/%1 [1] 409 > (4.1*10*10)%/%1 [1] 410 Shouldn't the result be 410 each time? I think in this case it should have returned all 0s, and I could have done something like newmat = as.integer(mat*100) dim(newmat) = dim(mat) rm(mat) Is there a better way to convert my double matrix to an integer matrix without losing precision? Or are there better ways to conserve memory? I'm at the limit. Thanks, Justin -- View this message in context: http://n4.nabble.com/Odd-result...
2011 Jun 23
2
Confidence interval from resampling
...3) #draw random numbers from a weibull distribution 100 times with shape=xwei.shape, scale = xwei.scale draw <- lapply(1:100, function(.x){ out<-rweibull(x, shape=xwei.shape, scale = xwei.scale) }) newx<- data.frame(draw) colnames(newx)<-paste("x", 1:100, sep = "") newmat<-data.matrix(newx) # matrix of coefficients rownum=2 colnum=100 ResultMat<-matrix(NA, ncol=colnum, nrow=rownum) rownum2=45 colnum2=100 ResultMat2<-matrix(NA, ncol=colnum2, nrow=rownum2) #loop through each column in the source matrix for (i in 1:100) { sel_col<-...
2008 Jan 29
2
help on establishing a matrix
I am a beginner and this is a naive question. I have the following data set. row column height 1 2 96 3 7 67 9 25 77 ...... I have a matrix of 50*100 data points and about 60% of them are zeros. I want to put the height data into the matrix according to their row and column numbers. does anybody have experience in setting up such matrix? Your help is highly appreciated. Jack LSU
2011 Mar 08
1
Replacing values in a data.frame/matrix
...t: m.perm <- matrix(c(2,1,3,1,2,3,3,2,1), ncol = 3, byrow=T) i.e. each 1 should map to 2 and vice verse while 3 maps to itself. What I've done so far is: permutateMatrix <- function(mat, perm=NULL) { values <- 1:NCOL(mat) if (is.null(perm)) { perm <- sample(values) } newmat <- replace(mat, sapply(values, function (val) which(mat==val)), rep(perm, each=NROW(mat))) return(list(mat.perm=newmat, perm=perm)) } "perm" is the permutation vector: 1 maps to the first element of perm, 2 to the second and so on. Thus, for the example we would use perm &l...
2007 Dec 19
0
leaps
....306 0.196038 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.08135 on 68 degrees of freedom Multiple R-Squared: 0.9932, Adjusted R-squared: 0.9914 F-statistic: 549.8 on 18 and 68 DF, p-value: < 2.2e-16* newmat <- cosmat[,-c(5,8,10,12,13,15,16,18,20:44)] newmat <- cbind(newmat,sinmat[,-c(7:11,13:44)]) Regmod <- regsubsets(newmat, yy) rs <- summary(Regmod) which.max(rs$adjr) *[1] 8 *rs$which[which.max(rs$adjr), ] *(Intercept) cos1 cos2 cos3 cos4 cos6...
2010 Apr 05
1
strange behavior of matrix
Dear R list, I have discovered a seemingly peculiar feature when using a matrix to index itself (yes, this is strange code, which I have now modified to be more reasonable). #this makes sense s <- matrix(1:3,nrow=1) s[s] #all three elements are shown #but when I try s <- matrix(1:2,nrow=1) s[1] #fine, the first element is shown s[2] #fine, the second element is
2012 Nov 12
1
reshape
Hi, I have a R output that looks as follow: Rad:0 Rad1:2 Rad3:3 I want to make a new matrix that looks like : sample size is 2400 Variable    n11  n12 Rad            0     2400-0=2400 Rad1          2       2400-2 Rad3  3      2400-3   Thanks a lot for your time and help:) Best,Farnoosh Sheikhi [[alternative HTML version deleted]]
2013 Nov 01
1
Package(s) for making waffle plot-like figures?
Dear all, I am trying to make a series of waffle plot-like figures for my data to visualize the ratios of amino acid residues at each position. For each one of 37 positions, there may be one to four different amino acid residues. So the data consist of the positions, what residues are there, and the ratios of residues. The ratios of residues at a position add up to 100, or close to 100 (more on
2013 Nov 22
2
[LLVMdev] new dragonegg 3.4 warning on darwin12
...claration of built-in function ‘strcpy’ [enabled by default] strcpy(size,argv[1]); ^ himenoBMTxpa.c: In function ‘set_param’: himenoBMTxpa.c:226:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default] exit(6); ^ himenoBMTxpa.c: In function ‘newMat’: himenoBMTxpa.c:239:5: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default] malloc(mnums * mrows * mcols * mdeps * sizeof(float)); ^ himenoBMTxpa.c: In function ‘clearMat’: himenoBMTxpa.c:248:5: warning: incompatible implicit declaration of built-...
2007 Aug 21
1
Random Sampling from a Matrix
...00 X 20. The first two columns are indicator variables taking the value of either 0 or 1. Let us call the first two columns Y1 and Y2. I need to randomly sample 1000 rows with all the associated columns, in other words my new matrix should be of size 1000 X 20. I realize that using this command newmat <- mainmat[sample(1000,replace=F),] achieves this. However, I would like to make sure that both Y1 and Y2 have more or less an equal amount of 0's and 1's. At present when I sample, I get cases where sometimes all my Y2's are 0. Is there any way to accomodate this problem. Thanks i...
2008 Apr 10
2
subtract the mean from each column
Hi, I am new to R an dI need some help I have a matrix of real values 100*300 and I would like to calculate the mean for each column , then for each entry in a column i need to subtract the mean so I will have a matrix where the columns have zero mean. any one know how to do that . Thanks -- View this message in context:
2010 Oct 12
2
extract rows of a matrix
Hi all, I want to extract every 20th row of a big matrix, say 10000 by 1000. What is the simper way to do this? Thank you very much! Hannah [[alternative HTML version deleted]]
1997 Aug 18
1
R-beta: bug report
The following seems to be a bug when I tried to use the predict function. > forbes boil.pt pressure log.pressure [1,] 194.5 20.79 303.4472 [2,] 194.3 20.79 303.4472 [3,] 197.9 22.40 310.9061 [4,] 198.4 22.67 312.1042 [5,] 199.4 23.15 314.1995 [6,] 199.9 23.35 315.0597 [7,] 200.9 23.89 317.3460 [8,] 201.1 23.99
2013 Nov 22
0
[LLVMdev] new dragonegg 3.4 warning on darwin12
...cpy’ [enabled by default] > strcpy(size,argv[1]); > ^ > himenoBMTxpa.c: In function ‘set_param’: > himenoBMTxpa.c:226:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default] > exit(6); > ^ > himenoBMTxpa.c: In function ‘newMat’: > himenoBMTxpa.c:239:5: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default] > malloc(mnums * mrows * mcols * mdeps * sizeof(float)); > ^ > himenoBMTxpa.c: In function ‘clearMat’: > himenoBMTxpa.c:248:5: warning: incompatible impli...
2007 Aug 24
1
uneven list to matrix
...2]] A 1 C 3 D 4 alph[[3]] A 1 D 4 E 5 I would like to create a matrix from the elements in the list with n columns such that the row names are preserved and NAs are inserted into the cells where the uneven lists do not match up based on their row names. Here is an example of the desired output: newmatrix [,1] [,2] [,3] A 1 1 1 B 2 NA NA C 3 3 NA D 4 4 4 E NA NA 5 Any suggestions? I have tried do.call("cbind",list) I also thought I was on the right track when I tried converting each element into a vector and then running this loop (which ul...