Re: [R] expand.gird with constraints?

2011-08-02 Thread Berwin A Turlach
G'day Kathie, On Tue, 2 Aug 2011 19:56:00 -0700 (PDT) Kathie wrote: > Hi, R users, > > Here is an example. > > k <- c(1,2,3,4,5) > i <- c(0,1,3,2,1) > > if k=1, then j=0 from i > if k=2, then j=0, 1 from i > if k=3, then j=0, 1, 2, 3 from i > if k=4, then j=0, 1, 2 from i > if k=5, then j=0,

[R] expand.gird with constraints?

2011-08-02 Thread Kathie
Hi, R users, Here is an example. k <- c(1,2,3,4,5) i <- c(0,1,3,2,1) if k=1, then j=0 from i if k=2, then j=0, 1 from i if k=3, then j=0, 1, 2, 3 from i if k=4, then j=0, 1, 2 from i if k=5, then j=0, 1 from i so i'd like to create a list like below. > list k j 1 1 0 2 2 0 3 2 1 4 3 0 5