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() successful

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

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.

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 combi