Re: [R] splitting data matrix into submatrices

2022-01-06 Thread Avi Gross via R-help
,] workweek <- mymat[!weekends,] Is this any better? -Original Message- From: Avi Gross via R-help To: r-help@r-project.org Sent: Wed, Jan 5, 2022 12:52 pm Subject: Re: [R] splitting data matrix into submatrices Faheem seems to reply to people in private and I replid to him in private bu

Re: [R] splitting data matrix into submatrices

2022-01-05 Thread Avi Gross via R-help
rom: Faheem Jan To: Avi Gross Sent: Tue, Jan 4, 2022 11:44 pm Subject: Re: [R] splitting data matrix into submatrices First I will thank you for your interest and time. As my first day is Sunday, in my data matrix 24 are hourly demand of electricity. As electricity demand is different is working

Re: [R] splitting data matrix into submatrices

2022-01-05 Thread Stephen H. Dawson, DSL via R-help
Hi, Please post the data structure so it is more clear what data is being massaged. Thanks, *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 1/4/22 10:52 PM, Faheem Jan via R-help wrote: I

Re: [R] splitting data matrix into submatrices

2022-01-05 Thread PIKAL Petr
at[which(fac==2), ] [,1] [,2] [,3] [,4] [1,]27 12 17 [2,]49 14 19 Cheers Petr > -Original Message- > From: R-help On Behalf Of Jeff Newmiller > Sent: Wednesday, January 5, 2022 8:57 AM > To: Faheem Jan ; R-help > Subject: Re: [R] splittin

Re: [R] splitting data matrix into submatrices

2022-01-04 Thread Jeff Newmiller
Please reply all so the mailing list is included in the discussion. I don't do 1:1 tutoring and others can chime in if I make a mistake. I would say you don't understand what my example did, since it doesn't care how many columns are in your data frame. If you are in fact working with a matrix,

Re: [R] splitting data matrix into submatrices

2022-01-04 Thread Jeff Newmiller
A lot of new R users fail to grasp what makes data frames more useful than matrices, or use data frames without even realizing they are not using matrices. This is important because there are more tools for manipulating data frames than matrices. One tool is the split function... if you have a

Re: [R] splitting data matrix into submatrices

2022-01-04 Thread Avi Gross via R-help
logical index wants.  If I have misunderstood the problem, ignore. -Original Message- From: Faheem Jan via R-help To: R-help Mailing List Sent: Tue, Jan 4, 2022 10:52 pm Subject: [R] splitting data matrix into submatrices I have data in a matrix form of order 1826*24 where 1826 represents

[R] splitting data matrix into submatrices

2022-01-04 Thread Faheem Jan via R-help
I have data in a matrix form of order 1826*24 where 1826 represents the days and 24 hourly observations on each data. My objective is to split the matrix into working (Monday to Friday) and non-working (Saturday and Sunday) submatrices. Can anyone help me that how I will do that splitting using

[R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread Hana Lee
Hi! I have a matrix called M with dimension (586,100,100). I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l-dim(M)[1] for (i in (1:l)){ save(M[i,,],file = M_[i].img) } Can somebody help me with

Re: [R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread Henrik Bengtsson
Hi, On Sun, Nov 21, 2010 at 9:27 PM, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). First of all, In R it is only an object with *two* dimensions that is called matrix. Anything with two or more dimensions is called an array. Example: x -

Re: [R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread Michael Bedward
Hi Hana, Use the paste function to create your file names. for ( i in 1:dim(M)[1] ) save( M[i,,], file=paste(M_, i, .img, sep=) ) Alternatively, use the sprintf function to get names with leading zeroes for easier sorting of files: for (i in 1:dim(M)[1] ) save( M[i,,], file=sprintf(M_%03d.img,

Re: [R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread Henrik Bengtsson
Sorry, I did a mistake corrected below. On Sun, Nov 21, 2010 at 9:50 PM, hb h...@biostat.ucsf.edu wrote: Hi, On Sun, Nov 21, 2010 at 9:27 PM, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). First of all, In R it is only an object with *two*

Re: [R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread David Winsemius
On Nov 22, 2010, at 12:27 AM, Hana Lee wrote: Hi! I have a matrix called M with dimension (586,100,100). In R you have an array (not a matrix) wehn the number of dimensions is 3. I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the

[R] Splitting a matrix

2010-09-16 Thread Megh Dal
Hi, I was trying to split the following matrix dat: set.seed(1) dat - matrix(rnorm(4*16), 4, 16) dat [,1] [,2] [,3][,4][,5][,6] [,7] [,8][,9] [,10] [,11] [1,] -0.6264538 0.3295078 0.5757814 -0.62124058 -0.01619026

Re: [R] Splitting a matrix

2010-09-16 Thread Bill.Venables
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Megh Dal Sent: Thursday, 16 September 2010 5:43 PM To: r-h...@stat.math.ethz.ch Subject: [R] Splitting a matrix Hi, I was trying to split the following matrix dat: set.seed(1) dat - matrix(rnorm(4*16), 4, 16) dat [,1