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
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 ha

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 v

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

Re: [R] splitting data frame into fixed rows depending on column rep

2015-12-06 Thread Jim Lemon
Hi Ragia, Perhaps the easiest way is to split the data frame into a list by the values of v1: sdf<-split(df,df$v1) Then rename the elements of sdf for convenience: names(sdf)<-paste("v1",1:5,sep="_") Now you can extract whatever you like" sdf$v1_1$v2 [1] 3 4 8 Of course if you only want the v

[R] splitting data frame into fixed rows depending on column rep

2015-12-06 Thread Ragia Ibrahim
Dear group, I have the following data frame             v1 v2  v3 v4 v5 1           1  3 1   3.5    1 2           1  4 3   3.5    1 3           1  8 3   3.5    1 4           2  9 8   2.5    1 5           2 10 9   2.5    1 6           2  6 3   1.5    1 7           3  4 3   2.0    1 8           3  

Re: [R] Splitting data frame into columns with dplyr

2015-10-01 Thread Giorgio Garziano
library(dplyr) df <- data.frame(z = rep(c("A", "B")), x = 1:6, y = 7:12) %>% arrange(z) temp <- reshape(df, v.names = c("x", "y"), idvar = c("x", "y"), timevar = "z", direction = "wide") lA <- na.omit(temp[,c("x.A", "y.A")]) lB <- na.omit(temp[,c("x.B", "y.B")]) df.long <- as.data.frame(cbind(lA,

Re: [R] Splitting data frame into columns with dplyr

2015-10-01 Thread Thierry Onkelinx
Dear Michael, You'll need a combination of dplyr and tidyr library(dplyr) library(tidyr) data.frame(id = rep(1:3, 2), z = rep(c("A", "B")), x = 1:6, y = 7:12) %>% arrange(z) %>% gather(variable, value, -z, -id) %>% mutate(newcol = paste(z, variable, sep = ".")) %>% select(-z, -variable)

[R] Splitting data frame into columns with dplyr

2015-10-01 Thread Michael . Laviolette
I have a data frame with a structure similar to the following. The variable z is a grouping variable; x and y are measurement variables. library(dplyr) df <- data.frame(z = rep(c("A", "B")), x = 1:6, y = 7:12) %>% arrange(z) z x y 1 A 1 7 2 A 3 9 3 A 5 11 4 B 2 8 5 B 4 10 6 B 6 12 I nee

Re: [R] splitting data

2014-09-09 Thread eliza botto
Dear Davis, Dennis and John, I am thankyou that you replied. I'll take care of it in future. Eliza > Date: Mon, 8 Sep 2014 17:36:30 -0700 > Subject: Re: [R] splitting data > From: djmu...@gmail.com > To: eliza_bo...@hotmail.com > > Hi Eliza: > > Here are a few po

Re: [R] splitting data

2014-09-08 Thread David Winsemius
On Sep 8, 2014, at 2:01 PM, David Winsemius wrote: > > On Sep 8, 2014, at 12:08 PM, eliza botto wrote: > >> >> > > This is typical use for base function aggregate: > >> with( dfrm, aggregate(dfrm[4:7], dfrm[1:2], FUN=sum)) > year month A B C D > 1 1961 1 78 102 138 258 > >>

Re: [R] splitting data

2014-09-08 Thread David Winsemius
On Sep 8, 2014, at 12:08 PM, eliza botto wrote: > Dear R members, > > I have this data frame of 100 years in the following format > > yearmonth day A B C D > > where A,B,C and D are item number sold each day. I am trying > > 1-split the

Re: [R] splitting data

2014-09-08 Thread John McKown
On Mon, Sep 8, 2014 at 2:08 PM, eliza botto wrote: > Dear R members, > > I have this data frame of 100 years in the following format > > yearmonth day A B C D > > where A,B,C and D are item number sold each day. I am trying > > 1-split the dat

Re: [R] splitting data

2014-09-08 Thread Bert Gunter
?tapply e.g. with(yourdata, tapply(A,list(year,month),sum,simplify=FALSE)) This assumes "sum them up" means summing each column separately. You were unclear as to exactly what you meant by this. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. I

[R] splitting data

2014-09-08 Thread eliza botto
Dear R members, I have this data frame of 100 years in the following format yearmonth day A B C D where A,B,C and D are item number sold each day. I am trying 1-split the data w.r.t the monthly values for each year 2-then, sum them up I

Re: [R] Splitting data into two camps

2013-09-16 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Evan Sticca > Sent: Friday, September 13, 2013 6:48 PM > To: r-help@r-project.org > Subject: [R] Splitting data into two camps > > Hello R-he

Re: [R] Splitting data into two camps

2013-09-14 Thread David Winsemius
On Sep 13, 2013, at 9:47 AM, Evan Sticca wrote: > Hello R-help, > > I have recently generated some meta-data on SNP variation across whole > exomes and I need to begin sorting it into two camps: one in which the > alternate allele matches the derived form and one where the alternate > allele mat

[R] Splitting data into two camps

2013-09-13 Thread Evan Sticca
Hello R-help, I have recently generated some meta-data on SNP variation across whole exomes and I need to begin sorting it into two camps: one in which the alternate allele matches the derived form and one where the alternate allele matches the ancestral form. I have the data saved as a .txt file

Re: [R] Splitting Data Into Different Series

2012-08-06 Thread arun
="3939") #or split the data dados1<-as.data.frame(dados) dados2<-split(dados1,dados1$code) - Original Message - From: Henrique Andrade To: r-help@r-project.org Cc: Sent: Monday, August 6, 2012 1:06 PM Subject: [R] Splitting Data Into Different Series Dear R Community,

Re: [R] Splitting Data Into Different Series

2012-08-06 Thread Henrique Andrade
Dear Rui and Arun, Thanks a lot for your help. I will test all the proposed solutions ;-) Best regards, Henrique Andrade 2012/8/6 Rui Barradas : > Hello, > > Try the following. > > split(data.frame(dados), dados[, "code"]) > > Also, it's better to have data like 'dados' in a data.frame, like thi

Re: [R] Splitting Data Into Different Series

2012-08-06 Thread Rui Barradas
Hello, Try the following. split(data.frame(dados), dados[, "code"]) Also, it's better to have data like 'dados' in a data.frame, like this you would have dates of class Date, and numbers of classes numeric or integer: dados2 <- data.frame(dados) dados2$date <- as.Date(dados2$date) dados2$v

[R] Splitting Data Into Different Series

2012-08-06 Thread Henrique Andrade
Dear R Community, I'm trying to write a loop to split my data into different series. I need to make a new matrix (or series) according to the series code. For instance, every time the "code" column assumes the value "433" I need to save "date", "value", and "code" into the "dados433" matrix. Ple

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Jessica Streicher
Ad_1 <- subset(Attrition_data_1,Attrition_ind=="1") Ad_0 <- subset(Attrition_data_1,Attrition_ind=="0") s1<-sample(1:dim(Ad_0)[1],0.8*dim(Ad_0)[1])# 80% of the non-attrites s2<-sample(1:dim(Ad_1)[1],0.8*dim(Ad_1)[1])# 80% of attritees s3<- Ad_0 [-s1,] summary(s3) s4<- Ad_1 [-s2,] summary(s4)

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Dwaipayan Dasgupta
Behalf Of Jessica Streicher Sent: Thursday, April 26, 2012 5:07 PM To: r-help@r-project.org Subject: Re: [R] Splitting data into test and train (80:20) kepping attributes similar Be reminded that s1 and s2 are only the indexes on AD_0 and AD_1 of the data which you want to keep. therefore traindata

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Jessica Streicher
> Would you help please > > Thanks, > Dwaipayan > > From: Jessica Streicher [mailto:j.streic...@micromata.de] > Sent: Wednesday, April 25, 2012 9:25 PM > To: Dwaipayan Dasgupta > Cc: r-help@r-project.org > Subject: Re: [R] Splitting data into test and train (80:20) keppi

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Frank Harrell
You can run simulations to find out how large N must be so that split sample validation yields sufficient precision to be trustworthy, in other words, that different random splits provide the same estimate of model accuracy to within some small tolerance. You will be surprised how large N must be

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Dwaipayan Dasgupta
M To: Dwaipayan Dasgupta Cc: r-help@r-project.org Subject: Re: [R] Splitting data into test and train (80:20) kepping attributes similar Don't know whats wrong there (except if you're using the eclipse R plugin on a mac like me and the window for choosing the download site doesn't pop

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Jessica Streicher
"sample.split" >> Could you please help >> >> Thanks in advance >> doy >> >> >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf Of Dwaipayan Dasgupta >> Sent: Tuesd

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Dwaipayan Dasgupta
roject.org Subject: Re: [R] Splitting data into test and train (80:20) kepping attributes similar Well, it throws an error, because there is no such function in default R. A bit of googling showed it might be the one in the caTools package. execute this: install.packages("caTools") libr

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Jessica Streicher
ample.split" > Could you please help > > Thanks in advance > doy > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Dwaipayan Dasgupta > Sent: Tuesday, April 24, 2012 9:08 PM > To: r-h

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Dwaipayan Dasgupta
lease help Thanks in advance doy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dwaipayan Dasgupta Sent: Tuesday, April 24, 2012 9:08 PM To: r-help@r-project.org Subject: [R] Splitting data into test and train (80:20) kepping

[R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-24 Thread Dwaipayan Dasgupta
Hi, I am trying to do some predictive modeling around attrition and want to split the dataset into test and train (80:20) and keep the ratio of attritees:non attrites same. In my dataset the attrition indicator is coded as 0(for non-attritees) and 1 (for attritees) and I want to keep the ratio o

Re: [R] Splitting data

2011-08-15 Thread Marina de Wolff
By the way, I indeed want to get the data returned. From: marinadewo...@hotmail.com To: michael.weyla...@gmail.com CC: r-help@r-project.org Subject: RE: [R] Splitting data Date: Mon, 15 Aug 2011 10:32:04 +0200 Dear Michael, I adjusted the code a bit; d1 = DataSplitsCore(Data1[(1:nr1

Re: [R] Splitting data

2011-08-15 Thread Marina de Wolff
Marina de Wolff From: michael.weyla...@gmail.com Date: Fri, 12 Aug 2011 11:50:30 -0400 Subject: Re: [R] Splitting data To: marinadewo...@hotmail.com CC: r-help@r-project.org Sorry -- missed a tweak. The call to DataSplitsCore should read nr = floor(NROW(Data)/2); Data1 = Data[(1:nr)]; Data

Re: [R] Splitting data

2011-08-12 Thread R. Michael Weylandt
a would be to split the data in half, compare with each other >> and if both groups (first half of the data and second half of the data) >> significantly differ split again and compare both left groups with each >> other and both right groups with each other etc. >>

Re: [R] Splitting data

2011-08-12 Thread R. Michael Weylandt
only use the groups with a minimum size of m. > > Many thanks in advance for your assitance in this. > > Sincerely, > > Marina de Wolff > > > -- > From: michael.weyla...@gmail.com > Date: Fri, 12 Aug 2011 09:35:00 -0400 > > Subject: Re: [

Re: [R] Splitting data

2011-08-12 Thread R. Michael Weylandt
; x <- data[1:round(m)] > y <- data[(round(m)+1):length(data)] > > x has size 9 and y has size 8. > > > Sincerely, > > Marina de Wolff > > ------ > From: michael.weyla...@gmail.com > Date: Thu, 11 Aug 2011 11:54:11 -0400 > Su

Re: [R] Splitting data

2011-08-12 Thread Marina de Wolff
ld use m <- length(data)/2 x <- data[1:round(m)] y <- data[(round(m)+1):length(data)] x has size 9 and y has size 8. Sincerely, Marina de Wolff From: michael.weyla...@gmail.com Date: Thu, 11 Aug 2011 11:54:11 -0400 Subject: Re: [R] Splitting data To: marinadewo...@hotmail.com CC: r

Re: [R] Splitting data

2011-08-11 Thread R. Michael Weylandt
This sounds very much like a recursive problem: something like this seems to get the gist of what you want. DataSplits <- function(Data, alpha = 0.05) { DataSplitsCore <- function(Data, alpha, level) { tt <- t.test(Data[,1],Data[,2]) print(tt) if (tt$p.value > alpha) {

[R] Splitting data

2011-08-11 Thread Marina de Wolff
I want to implement the following algorithm in R: I want to split my data, use a t test to compare both means of the groups to see if they significantly differ from each other. If this is a yes (p < alpha) I want to split again (into 4 groups) and do the same procedure twice, and stop otherw

Re: [R] Splitting data in to multiple boxplots

2010-09-29 Thread Joshua Wiley
Hi, The form of the data is not terribly important neither is whether it was sorted as boxplots are not order dependent are category "a" is "a" sorted or not. See below for individual plots with your new data. # read in data dat <- read.table(textConnection(" 1 a 12 2 b 4 3 a 3 4 c 54 5

Re: [R] Splitting data in to multiple boxplots

2010-09-29 Thread Martyn Byng
Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of deadlyspider Sent: 29 September 2010 11:02 To: r-help@r-project.org Subject: Re: [R] Splitting data in to multiple boxplots Ok, I don't think I was specific enough. Th

Re: [R] Splitting data in to multiple boxplots

2010-09-29 Thread deadlyspider
Ok, I don't think I was specific enough. The data originally came in this form 1 a 12 2 b 4 3 a 3 4 c 54 5 a 12 6 b 11 7 c 9 8 c 2 . . . . . . . . . Where I sorted by the second column (NB the second column is the categories and they have long names). I would then like

Re: [R] Splitting data in to multiple boxplots

2010-09-28 Thread Joshua Wiley
Hi, There is a very handy feature of boxplot() that will handle this easily. You can write formulae of the form: scores ~ groups For your sample data: # read in data dat <- read.table(textConnection(" id cat value 1 a12 2 a23 3 a14 4 b2 5 b3 6 c9 7 c8

[R] Splitting data in to multiple boxplots

2010-09-28 Thread deadlyspider
Hi, I have a data set in the following format: id cat value 1 a12 2 a23 3 a14 4 b2 5 b3 6 c9 7 c8 8 c10 9 d30 I would like to set up boxplots for each category. The actual category names are long and many so I would like this to be split

Re: [R] Splitting Data by Row

2009-06-20 Thread Jim Lemon
Ross Culloch wrote: Hello fellow R users! I wonder if someone can help with what i think should be a simple question but i can't seem to find the answer or work it out. My data set is as such: Day Time ID Behaviour 1 9 A1 2 1 10A2 3 .. .... .. 4 10

Re: [R] Splitting Data by Row

2009-06-19 Thread Ross Culloch
OF COURSE Well, i waited until 16:00 before making the first obvious mistake of the day! Despite 4 hours working on the data I just didn't think! You got the question, i just missed the obvious! Thanks very much, & sorry for not noticing that and trying to make life even more complicated

Re: [R] Splitting Data by Row

2009-06-19 Thread Uwe Ligges
Ross Culloch wrote: Hello fellow R users! I wonder if someone can help with what i think should be a simple question but i can't seem to find the answer or work it out. My data set is as such: Day Time ID Behaviour 1 9 A1 2 1 10A2 3 .. .... .. 4

[R] Splitting Data by Row

2009-06-19 Thread Ross Culloch
Hello fellow R users! I wonder if someone can help with what i think should be a simple question but i can't seem to find the answer or work it out. My data set is as such: Day Time ID Behaviour 1 9 A1 2 1 10A2 3 .. .... .. 4 10 A1 10 4 1

Re: [R] Splitting Data Frame into Two Based on Source Array

2008-09-08 Thread Adam D. I. Kramer
data_main[ match(src,data_main$V1), ] and the compliment of src (call it srcc) data_main[ match(srcc,data_main$V1), ] ...this only works so long as there is only one occurrance of each item in V1 in V1. --Adam On Tue, 9 Sep 2008, Gundala Viswanath wrote: Dear all, Suppose I have this data

Re: [R] Splitting Data Frame into Two Based on Source Array

2008-09-08 Thread Gabor Grothendieck
Try this which gives a list of two data frames: split(data_main, data_main$V1 %in% c("foo", "bar")) On Mon, Sep 8, 2008 at 11:17 PM, Gundala Viswanath <[EMAIL PROTECTED]> wrote: > Dear all, > > Suppose I have this data frame: > > >> data_main > V1 V2 > foo13.1 > bar 12.0 > qux 10.4 >

Re: [R] Splitting Data Frame into Two Based on Source Array

2008-09-08 Thread Jorge Ivan Velez
Dear Gundala, Try this: # Data set data_main=read.table(textConnection("V1 V2 foo13.1 bar 12.0 qux 10.4 cho 20.33 pox 8.21"),header=TRUE) attach(data_main) closeAllConnections() # Criteria src=c('bar','pox') # data_child1 data_main[V1%in%src,] # data_child2_complement data_main[!V1

[R] Splitting Data Frame into Two Based on Source Array

2008-09-08 Thread Gundala Viswanath
Dear all, Suppose I have this data frame: > data_main V1 V2 foo13.1 bar 12.0 qux 10.4 cho 20.33 pox 8.21 And I want to split the data into two parts first part are the one contain in the source array: > src [1] "bar" "pox" and the other one the complement. In the end we hope t

Re: [R] splitting data frame based on a criteria

2008-06-04 Thread Petr PIKAL
Hi the other possible option is to use split with suitable graphing technique or with lapply and appropriate function e.g. boxplot(split(X, Y>0)) histogram( ~ X|Y) gives Marvin [EMAIL PROTECTED] napsal dne 03.06.2008 21:11:29: > ?by may be helpful here > eg if dat is your data.frame and yf i

Re: [R] splitting data frame based on a criteria

2008-06-03 Thread ctu
Or ?gsummary Quoting Moshe Olshansky <[EMAIL PROTECTED]>: Also check ?aggregate --- On Wed, 4/6/08, Ingmar Visser <[EMAIL PROTECTED]> wrote: From: Ingmar Visser <[EMAIL PROTECTED]> Subject: Re: [R] splitting data frame based on a criteria To: "Marvin Lists" &l

Re: [R] splitting data frame based on a criteria

2008-06-03 Thread Moshe Olshansky
Also check ?aggregate --- On Wed, 4/6/08, Ingmar Visser <[EMAIL PROTECTED]> wrote: > From: Ingmar Visser <[EMAIL PROTECTED]> > Subject: Re: [R] splitting data frame based on a criteria > To: "Marvin Lists" <[EMAIL PROTECTED]> > Cc: r-help@r-project.org &

Re: [R] splitting data frame based on a criteria

2008-06-03 Thread Ingmar Visser
?by may be helpful here eg if dat is your data.frame and yf is a factor (created using ifelse) use by(dat,yf,mean) to compute the means for each level of yf hth, Ingmar On Jun 3, 2008, at 8:37 PM, Marvin Lists wrote: Hi, I have a data frame that I want to split into two based on the values of

[R] splitting data frame based on a criteria

2008-06-03 Thread Marvin Lists
Hi, I have a data frame that I want to split into two based on the values of a variable in it. The variable Y has numeric values ranging between 0 through 70. I want to plot the frequencies of another variable X in two different cases: - When Y = 0 and - When Y > 0 How does one go about doing thi

[R] Splitting data

2008-03-18 Thread Kathy Maher
Does anyone know a loop that will allow me to split rows of data to get sum of squares; and then to move rows around to minimize the sum of squares? I am stuck on how to split and move rows around. [[alternative HTML version deleted]] __ R-help@