Hi:

try this and have a look at ?cut just to change the lables:

data.frame(
weeks=sprintf('%s %d','week',1:30),
specialweeks=cut(1:30,c(0,2,5,12,18,19,20),right = FALSE))

Andrija

On Tue, Apr 5, 2011 at 1:20 PM, beatleb <rhelpforum@gmail.com> wrote:

> Dear R-useRs,
>
> I am looking for a why to perform the following:
>
> specialweeks<-c(0,2,5,12,18,19,20)
> weeks<-c(1:30)
>
> Now I would like that for every week it is even between which elements of
> vector special weeks it is.
> For weeks after 20, the value NA or 20, or even 20-30is fine.
>
> Thus for
> week 1: 0-2
> week 2: 2-5
> week 3: 2-5
> week 4: 2-5
> week 5: 5-12
> ect....
>
> It is not relevant if those intervals are captured in a matrix, in a vector
> or whatever.
>
> I hope that you can help me!
>
> With best regards,
>
> Brenda Grondman
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Value-between-which-elements-of-a-vector-tp3427751p3427751.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

