[R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Hosack, Michael
Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I used expand.grid() successfully(?) to create my dataframe,

[R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Hosack, Michael
Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I used expand.grid() successfully(?) to create my dataframe,

Re: [R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Jorge Ivan Velez
Hi Mike, Try this: SITE - c(101,102,103,104) WDAY - c('MON','TUE','WED','THR','FRI') TOD - c('MORN', 'AFTN') out - expand.grid(SITE, WDAY, TOD) out HTH, Jorge On Thu, Mar 25, 2010 at 4:21 PM, Hosack, Michael wrote: Hello, I need to create a dataframe containing all possible combinations

Re: [R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Rolf Turner
On 26/03/2010, at 9:22 AM, Hosack, Michael wrote: Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I

Re: [R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Stephan Kolassa
Hi Mike, the following works for me: SITE - ordered(c(101,102,103,104)) WDAY - ordered(c(MON,TUE,WED,THR,FRI),levels=c(MON,TUE,WED,THR,FRI)) TOD - ordered(c(MORN,AFTN),levels=c(MORN,AFTN)) foo - expand.grid(SITE=SITE,WDAY=WDAY,TOD=TOD) foo[order(foo$SITE),] If this doesn't solve your

Re: [R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Erik Iverson
Hello, Hosack, Michael wrote: Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I used expand.grid()