[R] create one bigger matrix with one smaller matrix

2015-12-31 Thread Kathryn Lord
Dear R users, Suppose that I have a matrix A A <- matrix(c(1,2,3,4),2,2) > A [,1] [,2] [1,]13 [2,]24 With this matrix A, I'd like to create bigger one, for example, [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,]1313

[R] elegant way to create a sequence with the 'rep' bulit-in function

2015-05-23 Thread Kathryn Lord
Dear R users, I'd like to create a sequence/vector, for example, 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 4 4 4 4 5 5 5 5 4 4 4 4 5 5 5 5 4 4 4 4 5 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 6 6 6 7 7 7 8 8 8 9 9 9 So I did like this below. a - 4 b - 3 c - 2 grp - c( rep(1:b, each=c,

[R] how to draw a legend outside of the plot

2015-02-04 Thread Kathryn Lord
Dear R users, I have three plots, so I tried, for exmple, par(mfrow=c(2,2)) y1 - rnorm(100) y2 - rnorm(100) y3- rnorm(100) plot(y1);plot(y2);plot(y3) Here, I'd like to put a legend on the bottom right hand side (empty space). is it possible? Thanks for helping, Kathryn Lord

[R] create a function with subset statement

2015-01-28 Thread Kathryn Lord
no idea how to do that. Any suggestion will be greatly appreciated. Kathryn Lord [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] create new matrices with specific patterns

2015-01-26 Thread Kathryn Lord
); in other words, Is there the easyiest way to create B,...,E in R? Actually, the example above is a toy example and the matrix A I have is around 10,000 by 10,000 and the pattern is also very complicated. Any suggestion will be greatly appreciated. Best, Kathryn Lord [[alternative HTML

Re: [R] create new matrices with specific patterns

2015-01-26 Thread Kathryn Lord
, Jan 27, 2015 at 11:47 AM, Kathryn Lord kathryn.lord2...@gmail.com wrote: Dear R users, Suppose I have a matrix A. p - 1:4 q - 1:5 P-rep(p, each=5) Q-rep(q, 4) A - cbind(P,Q) A P Q [1,] 1 1 [2,] 1 2 [3,] 1 3 [4,] 1 4 [5,] 1 5 [6,] 2 1 [7,] 2 2 [8,] 2 3 [9

[R] sum of grouped elements of vector

2015-01-23 Thread Kathryn Lord
R? Any suggestion will be greatly appreciated. Best, Kathryn Lord [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] create matrices with constraint

2014-12-12 Thread Kathryn Lord
. Using same logic, I'd like to make the matrices (a3, a4, a5) as many as possible. Any suggestion will be greatly appreciated. Best, Kathryn Lord [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE

[R] make matrices as many as possible with a constraint

2014-12-11 Thread Kathryn Lord
[3,] 15 16 17 18 19 20 21 [4,] 22 23 24 25 26 27 28 Matrices a1 and a2 have different columns, and I guess there are such many matrices. Any suggestion will be greatly appreciated. Best, Kathryn Lord [[alternative HTML version deleted

[R] pair-wise computation of columns in a matrix

2014-01-26 Thread Kathryn Lord
(uu[,3],uu[,5]) rho_45 - rho(uu[,4],uu[,5]) Actually, the matrix uu is huge, 20*1000. Would you plz tell me how to calculate rho, more efficiently?? Any suggestion will be greatly appreciated. Best, Kathryn Lord [[alternative HTML version deleted

[R] replace NA with another vector

2013-12-24 Thread Kathryn Lord
Dear R users, I have two different vectors like below x - c( NA, NA, 3, NA, 1) y - c( 20, 40 ,50) Combining x and y, I'd like to create new vector z z - c(20, 40, 3, 50, 1) Any suggestion will be greatly appreciated. Best, Kathryn Lord [[alternative HTML version deleted

[R] matrix manipulation with its rows

2013-01-16 Thread Kathryn Lord
] [,4] [,5] [,6] [1,]79 11 000 [2,] 0008 10 12 [[3]] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 13 15 17 000 [2,] 000 14 16 18 Any suggestion will be greatly appreciated. Regards, Kathryn Lord

[R] Table to matrix

2010-05-24 Thread Kathryn Lord
appreciated. Regrads, Kathryn Lord p.s. Here is R code. -- dat - as.data.frame(matrix( c( 2, 1, 1, 3, 1, 1, 6, 1, 0, 5, 0, 0), 4, 3, byrow=T)) covar - apply(dat[,-1],1,paste,collapse='') sp.dat - split(dat,covar) y.covar - lapply