# [R] Creating a before-and-after variable in R

Richard O'Keefe r@oknz @end|ng |rom gm@||@com
Fri Oct 4 00:20:51 CEST 2019

```Can we do this very simply?
My understanding is that you have a column where all the elements are
zero except for perhaps a single one.
Consider an example 0 0 1 0 0 where you want -2 -1 0 1 2.  This is 1 2
3 4 5 - 3.
> v <- c(0,0,1,0,0)
> w <- which(v == 1)
> a <- seq(along=v) - if (length(w) == 0) 0 else w[1]
> a
[1] -2 -1  0  1  2

I may have misunderstood and you may want -2 -1 1 2 3.  If so, just
> a <- a + (a >= 0)
will do the trick.

On Fri, 4 Oct 2019 at 03:46, Faradj Koliev <faradj.g using gmail.com> wrote:
>
> Thank you very much for your help!
>
> All the best,
>
> > 3 okt. 2019 kl. 16:37 skrev Eric Berger <ericjberger using gmail.com>:
> >
> > You can replace the last line in my first suggestion by the following two lines
> >
> > d <- 2014  # the default (set by the user)
> > a\$treatment <- sapply( 1:nrow(a), function(i) { b <- v[a\$country_code[i]]; a\$year[i] - ifelse(is.na(b),d,b)})
> >
> > Best,
> > Eric
> >
> >
> >
> >
> >
> > On Thu, Oct 3, 2019 at 5:19 PM Faradj Koliev <faradj.g using gmail.com> wrote:
> > Hi,
> >
> > I was thinking that it could simply show the negative counts. For ex: if a country hasn’t introduced the policy X, and it's in the dataset from 1982 to 2014, then the treatment variable would take a value -33 in 1982 and -1 in 2014.
> >
> > Best,
> >
> >
> > > 3 okt. 2019 kl. 16:11 skrev Eric Berger <ericjberger using gmail.com>:
> > >
> > > What should the treatment variable be in those cases? If you want to set it to a constant y (such as y=0), you can add something like
> > >
> > > y <- 0
> > > a\$treatment[ is.na(a\$treatment) ] <- y
> > >
> > > HTH,
> > > Eric
> > >
> > >
> > > On Thu, Oct 3, 2019 at 4:54 PM Faradj Koliev <faradj.g using gmail.com> wrote:
> > > Dear Eric,
> > >
> > > Thank you very much for this - it worked perfectly!
> > >
> > > A small thing: I wonder whether it’s possible to include those cases where the x is =0 for the whole study period. I have countries with x=0 for the whole period and the treatment variable is=NA for these observations.
> > >
> > > Best,
> > >
> > >
> > > > 3 okt. 2019 kl. 15:18 skrev Eric Berger <ericjberger using gmail.com>:
> > > >
> > > > Hi Faradj,
> > > > Suppose your data frame is labeled 'a'. Then the following seems to do what you want.
> > > >
> > > > v <- rep(NA_integer_,max(a\$country_code))
> > > > v[ a\$country_code[a\$x==1] ] <- a\$year[a\$x==1]
> > > > a\$treatment <- sapply( 1:nrow(a), function(i) { a\$year[i] - v[a\$country_code[i]]})
> > > >
> > > > HTH,
> > > > Eric
> > > >
> > > >
> > > > On Thu, Oct 3, 2019 at 3:36 PM Faradj Koliev <faradj.g using gmail.com> wrote:
> > > > Dear Michael Dewey,
> > > >
> > > > Thanks for reaching out about this. I trying again, now with plain text, and hope it works.
> > > >
> > > > Best,
> > > >
> > > >
> > > >
> > > > Dear R-users,
> > > >
> > > > I need an urgent help with the following: I have a country-year data covering the period 1982 - 2013. I want to assess how the variable X (a certain policy) affects the Y variable. The X variable is =1 when a country introduces that policy in a specific year, otherwise =0.
> > > >
> > > > What I want to do is to create a treatment variable, that would be a negative count until the X=1, and then  positive counts  for the years after X=1.
> > > >
> > > > For example, let’s say that the U.S. introduced the policy x in year 2000. The treatment variable would look be like this:
> > > >
> > > > country
> > > >
> > > > year
> > > >
> > > > x
> > > >
> > > > treatment
> > > >
> > > > USA
> > > >
> > > > 1982
> > > >
> > > > 0
> > > >
> > > > -18
> > > >
> > > > USA
> > > >
> > > > 1983
> > > >
> > > > 0
> > > >
> > > > -17
> > > >
> > > > USA
> > > >
> > > > 1984
> > > >
> > > > 0
> > > >
> > > > -16
> > > >
> > > > USA
> > > >
> > > > 1985
> > > >
> > > > 0
> > > >
> > > > -15
> > > >
> > > > USA
> > > >
> > > > 1986
> > > >
> > > > 0
> > > >
> > > > -14
> > > >
> > > > USA
> > > >
> > > > 1987
> > > >
> > > > 0
> > > >
> > > > -13
> > > >
> > > > USA
> > > >
> > > > 1988
> > > >
> > > > 0
> > > >
> > > > -12
> > > >
> > > > USA
> > > >
> > > > 1989
> > > >
> > > > 0
> > > >
> > > > -11
> > > >
> > > > USA
> > > >
> > > > 1990
> > > >
> > > > 0
> > > >
> > > > -10
> > > >
> > > > USA
> > > >
> > > > 1991
> > > >
> > > > 0
> > > >
> > > > -9
> > > >
> > > > USA
> > > >
> > > > 1992
> > > >
> > > > 0
> > > >
> > > > -8
> > > >
> > > > USA
> > > >
> > > > 1993
> > > >
> > > > 0
> > > >
> > > > -7
> > > >
> > > > USA
> > > >
> > > > 1994
> > > >
> > > > 0
> > > >
> > > > -6
> > > >
> > > > USA
> > > >
> > > > 1995
> > > >
> > > > 0
> > > >
> > > > -5
> > > >
> > > > USA
> > > >
> > > > 1996
> > > >
> > > > 0
> > > >
> > > > -4
> > > >
> > > > USA
> > > >
> > > > 1997
> > > >
> > > > 0
> > > >
> > > > -3
> > > >
> > > > USA
> > > >
> > > > 1998
> > > >
> > > > 0
> > > >
> > > > -2
> > > >
> > > > USA
> > > >
> > > > 1999
> > > >
> > > > 0
> > > >
> > > > -1
> > > >
> > > > USA
> > > >
> > > > 2000
> > > >
> > > > 1
> > > >
> > > > 0
> > > >
> > > > USA
> > > >
> > > > 2001
> > > >
> > > > 0
> > > >
> > > > 1
> > > >
> > > > USA
> > > >
> > > > 2002
> > > >
> > > > 0
> > > >
> > > > 2
> > > >
> > > > USA
> > > >
> > > > 2003
> > > >
> > > > 0
> > > >
> > > > 3
> > > >
> > > > USA
> > > >
> > > > 2004
> > > >
> > > > 0
> > > >
> > > > 4
> > > >
> > > > USA
> > > >
> > > > 2005
> > > >
> > > > 0
> > > >
> > > > 5
> > > >
> > > > USA
> > > >
> > > > 2006
> > > >
> > > > 0
> > > >
> > > > 6
> > > >
> > > > USA
> > > >
> > > > 2007
> > > >
> > > > 0
> > > >
> > > > 7
> > > >
> > > > USA
> > > >
> > > > 2008
> > > >
> > > > 0
> > > >
> > > > 8
> > > >
> > > > USA
> > > >
> > > > 2009
> > > >
> > > > 0
> > > >
> > > > 9
> > > >
> > > > USA
> > > >
> > > > 2010
> > > >
> > > > 0
> > > >
> > > > 10
> > > >
> > > > USA
> > > >
> > > > 2011
> > > >
> > > > 0
> > > >
> > > > 11
> > > >
> > > > USA
> > > >
> > > > 2012
> > > >
> > > > 0
> > > >
> > > > 12
> > > >
> > > > USA
> > > >
> > > > 2013
> > > >
> > > > 0
> > > >
> > > > 13
> > > >
> > > >
> > > >
> > > > Do you have any idea as how I can generate this? All suggestions are appreciated!
> > > >
> > > >
> > > > I’ve tried to create it but failed. I only could generate positive counts using this code:
> > > > require(data.table)
> > > > setDT(data)[,treatment := seq.int(0,.N-1L), by = cumsum(x)-x]
> > > >
> > > > My sample below:
> > > > dput(data)
> > > > structure(list(country_code = c(900L, 900L, 900L, 900L, 900L,
> > > > 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L,
> > > > 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L,
> > > > 900L, 900L, 900L, 900L, 900L, 305L, 305L, 305L, 305L, 305L, 305L,
> > > > 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L,
> > > > 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L,
> > > > 305L, 305L, 305L, 305L, 140L, 140L, 140L, 140L, 140L, 140L, 140L,
> > > > 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L,
> > > > 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L,
> > > > 140L, 140L, 140L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L,
> > > > 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L,
> > > > 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L,
> > > > 471L, 471L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L,
> > > > 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L,
> > > > 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L,
> > > > 352L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L,
> > > > 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L,
> > > > 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L,
> > > > 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L,
> > > > 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L,
> > > > 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 220L,
> > > > 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L,
> > > > 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L,
> > > > 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 481L, 481L,
> > > > 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L,
> > > > 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L,
> > > > 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 367L, 367L, 367L,
> > > > 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L,
> > > > 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 570L, 570L,
> > > > 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L,
> > > > 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L,
> > > > 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 212L, 212L, 212L,
> > > > 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L,
> > > > 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L,
> > > > 212L, 212L, 212L, 212L, 212L, 212L, 212L, 359L, 359L, 359L, 359L,
> > > > 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L,
> > > > 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 600L, 600L, 600L,
> > > > 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L,
> > > > 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L,
> > > > 600L, 600L, 600L, 600L, 600L, 600L, 600L, 565L, 565L, 565L, 565L,
> > > > 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L,
> > > > 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 235L, 235L,
> > > > 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L,
> > > > 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L,
> > > > 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 317L, 317L, 317L,
> > > > 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L,
> > > > 317L, 317L, 317L, 317L, 317L, 317L, 317L, 230L, 230L, 230L, 230L,
> > > > 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L,
> > > > 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L,
> > > > 230L, 230L, 230L, 230L, 230L, 230L, 380L, 380L, 380L, 380L, 380L,
> > > > 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L,
> > > > 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L,
> > > > 380L, 380L, 380L, 380L, 380L, 640L, 640L, 640L, 640L, 640L, 640L,
> > > > 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L,
> > > > 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L,
> > > > 640L, 640L, 640L, 640L, 500L, 500L, 500L, 500L, 500L, 500L, 500L,
> > > > 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L,
> > > > 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L,
> > > > 500L, 500L, 500L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L,
> > > > 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L,
> > > > 369L, 369L, 369L, 369L, 101L, 101L, 101L, 101L, 101L, 101L, 101L,
> > > > 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L,
> > > > 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L,
> > > > 101L, 101L, 101L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L,
> > > > 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L,
> > > > 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L,
> > > > 551L, 551L), year = c(1982L, 1983L, 1984L, 1985L, 1986L, 1987L,
> > > > 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
> > > > 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
> > > > 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L,
> > > > 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L,
> > > > 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
> > > > 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
> > > > 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L,
> > > > 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
> > > > 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
> > > > 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
> > > > 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
> > > > 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
> > > > 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
> > > > 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L,
> > > > 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L,
> > > > 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L,
> > > > 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
> > > > 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L,
> > > > 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L,
> > > > 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L,
> > > > 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L,
> > > > 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L,
> > > > 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L,
> > > > 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L,
> > > > 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L,
> > > > 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
> > > > 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
> > > > 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L,
> > > > 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
> > > > 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
> > > > 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
> > > > 2011L, 2012L, 2013L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
> > > > 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
> > > > 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L,
> > > > 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L,
> > > > 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
> > > > 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
> > > > 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L,
> > > > 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
> > > > 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
> > > > 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
> > > > 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
> > > > 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
> > > > 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L,
> > > > 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L,
> > > > 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L,
> > > > 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
> > > > 2013L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
> > > > 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
> > > > 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L,
> > > > 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
> > > > 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
> > > > 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
> > > > 2011L, 2012L, 2013L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L,
> > > > 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L,
> > > > 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L,
> > > > 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L,
> > > > 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L,
> > > > 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L,
> > > > 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L,
> > > > 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
> > > > 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
> > > > 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L,
> > > > 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
> > > > 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
> > > > 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
> > > > 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L,
> > > > 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
> > > > 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
> > > > 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1991L,
> > > > 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
> > > > 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
> > > > 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L,
> > > > 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
> > > > 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
> > > > 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
> > > > 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
> > > > 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
> > > > 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
> > > > 2009L, 2010L, 2011L, 2012L, 2013L), y = c(5.079999924, 5.079999924,
> > > > 5.829999924, 5.829999924, 5.829999924, 5.829999924, 5.829999924,
> > > > 5.829999924, 5.829999924, 5.829999924, 5.829999924, 5.829999924,
> > > > 9.170000076, 9.170000076, 8.159999847, 8.159999847, 8.159999847,
> > > > 8.159999847, 8.159999847, 8.079999924, 8.079999924, 8.079999924,
> > > > 8.079999924, 7.989999771, 7.989999771, 7.989999771, 7.989999771,
> > > > 7.989999771, 7.989999771, 7.989999771, 7.989999771, 7.989999771,
> > > > 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > 9.170000076, 9.670000076, 9.670000076, 9.670000076, 9.670000076,
> > > > 9.670000076, 9.670000076, 9.670000076, 9.670000076, 9.670000076,
> > > > 9.670000076, 9.670000076, 7.329999924, 7.329999924, 7.329999924,
> > > > 7.329999924, 7.329999924, 7.329999924, 4, 4, 4, 4, 4, 4, 4, 4,
> > > > 4, 4, 3.670000076, 3.670000076, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> > > > 4, 4.090000153, 4.090000153, 4.090000153, 6.489999771, 6.489999771,
> > > > 6.489999771, 6.489999771, 6.489999771, 6.489999771, 6.489999771,
> > > > 6.489999771, 6.489999771, 6.489999771, 6.739999771, 7.610000134,
> > > > 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > 8.329999924, 8.329999924, 7.869999886, 7.869999886, 7.869999886,
> > > > 7.869999886, 7.869999886, 7.869999886, 7.869999886, 7.869999886,
> > > > 7.869999886, 7.869999886, 7.869999886, 7.869999886, 7.869999886,
> > > > 7.869999886, 7.869999886, 7.869999886, 7.869999886, 7.869999886,
> > > > 7.869999886, 7.869999886, 13.42000008, 13.42000008, 13.42000008,
> > > > 13.42000008, 13.42000008, 13.42000008, 13.42000008, 13.42000008,
> > > > 13.42000008, 13.42000008, 13.42000008, 13.42000008, 8, 8, 11,
> > > > 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
> > > > 8.670000076, 8.670000076, 8.670000076, 8.670000076, 8.670000076,
> > > > 8.670000076, 8.670000076, 8.670000076, 8.670000076, 8.670000076,
> > > > 8.670000076, 8.670000076, 8.670000076, 9.770000458, 9.770000458,
> > > > 9.770000458, 9.770000458, 9.43999958, 9.43999958, 9.43999958,
> > > > 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958,
> > > > 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958,
> > > > 9.43999958, 9.539999962, 9.539999962, 9.539999962, 9.539999962,
> > > > 9.539999962, 9.539999962, 9.539999962, 9.539999962, 9.539999962,
> > > > 9.539999962, 9.539999962, 9.539999962, 7.159999847, 7.159999847,
> > > > 7.159999847, 7.159999847, 7.489999771, 7.489999771, 7.489999771,
> > > > 7.489999771, 7.489999771, 7.489999771, 7.489999771, 7.489999771,
> > > > 7.489999771, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > 8.699999809, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > 8.699999809, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > 8.699999809, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > 13.98999977, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > 13.92000008, 13.92000008, 13.92000008, 6.829999924, 6.829999924,
> > > > 6.829999924, 6.829999924, 6.829999924, 6.829999924, 6.829999924,
> > > > 6.829999924, 6.829999924, 6.829999924, 11.06000042, 11.06000042,
> > > > 11.06000042, 11.06000042, 11.06000042, 11.06000042, 11.06000042,
> > > > 11.06000042, 11.06000042, 11.06000042, 11.06000042, 11.72999954,
> > > > 11.72999954, 11.72999954, 11.72999954, 11.72999954, 11.72999954,
> > > > 11.72999954, 11.72999954, 11.72999954, 11.72999954, 11.72999954,
> > > > 4.989999771, 4.989999771, 4.989999771, 4.989999771, 4.989999771,
> > > > 4.989999771, 4.989999771, 11.17000008, 11.17000008, 11.17000008,
> > > > 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > 11.17000008, 11.17000008, 14.02000046, 14.02000046, 14.02000046,
> > > > 14.02000046, 14.02000046, 14.02000046, 14.02000046, 14.02000046,
> > > > 14.02000046, 14.02000046, 14.02000046, 14.02000046, 6.920000076,
> > > > 6.920000076, 6.920000076, 6.920000076, 6.920000076, 6.920000076,
> > > > 6.920000076, 6.920000076, 6.920000076, 6.920000076, 6.920000076,
> > > > 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > 8.010000229, 10.96000004, 11.19999981, 11.19999981, 11.19999981,
> > > > 11.19999981, 11.19999981, 11.19999981, 11.19999981, 11.19999981,
> > > > 11.19999981, 11.19999981, 2.170000076, 2.170000076, 13.57999992,
> > > > 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > 13.57999992, 8.619999886, 8.619999886, 8.619999886, 8.619999886,
> > > > 8.619999886, 8.619999886, 8.619999886, 14.60999966, 14.60999966,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 12.42000008, 12.42000008, 12.42000008,
> > > > 12.42000008, 12.42000008, 12.42000008, 11.92000008, 11.92000008,
> > > > 11.92000008, 11.59000015, 11.31999969, 14.26000023, 14.26000023,
> > > > 14.26000023, 14.26000023, 14.26000023, 14.26000023, 14.26000023,
> > > > 14.26000023, 13.93000031, 13.93000031, 13.93000031, 13.93000031,
> > > > 13.93000031, 13.93000031, 14.60000038, 14.60000038, 14.60000038,
> > > > 14.60000038, 13.5, 13.5, 14.26000023, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > 14.59000015, 12.43000031, 12.43000031, 12.43000031, 12.43000031,
> > > > 13.15999985, 13.15999985, 13.15999985, 13.15999985, 13.15999985,
> > > > 13.15999985, 13.15999985, 13.15999985, 13.15999985, 13.15999985,
> > > > 13.15999985, 13, 13, 13.15999985, 13.15999985, 12.82999992, 12.82999992,
> > > > 12.82999992, 12.82999992, 12.82999992, 12.82999992, 12.82999992,
> > > > 12.82999992, 12.82999992, 12.82999992, 12.82999992, 12.82999992,
> > > > 12.82999992, 12.82999992, 12.82999992, 12.82999992, 12.82999992,
> > > > 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042,
> > > > 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042,
> > > > 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042,
> > > > 8.31000042, 8.31000042, 8.31000042, 12.11999989, 12.11999989,
> > > > 12.11999989, 12.11999989, 12.11999989, 12.11999989, 12.11999989,
> > > > 12.11999989, 12.11999989, 12.11999989, 12.11999989, 2.170000076,
> > > > 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > 2.170000076, 2.170000076, 2.170000076, 7.829999924, 7.829999924,
> > > > 7.829999924, 7.829999924, 7.829999924, 7.829999924, 7.829999924,
> > > > 7.829999924, 14.23999977, 13.98999977, 13.98999977, 13.98999977,
> > > > 13.98999977, 13.98999977, 13.98999977, 13.98999977, 13.98999977,
> > > > 13.98999977, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > 13.92000008, 13.92000008, 13.92000008, 13.92000008, 6.96999979,
> > > > 7.46999979, 7.46999979, 7.46999979, 7.46999979, 7.46999979, 7.46999979,
> > > > 7.46999979, 7.46999979, 11.59000015, 11.59000015, 11.59000015,
> > > > 11.59000015, 11.59000015, 11.59000015, 11.59000015, 11.59000015,
> > > > 11.59000015, 11.59000015, 11.59000015, 15.25, 15.25, 15.25, 15.25,
> > > > 15.25, 15.25, 15.25, 15.25, 15.25, 15.25, 15.25, 15.25, 2.329999924,
> > > > 2.329999924, 2.329999924, 2.329999924, 2.329999924, 2.329999924,
> > > > 2.329999924, 2.329999924, 2.329999924, 2.329999924, 2.329999924,
> > > > 2.329999924, 4.329999924, 4.329999924, 4.329999924, 12, 12, 12,
> > > > 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12), x = c(0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0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 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > 0L)), .Names = c("country_code", "year", "y", "x"), class = "data.frame", row.names = c(NA,
> > > > -722L))
> > > >
> > > >
> > > >
> > > >
> > > > > 3 okt. 2019 kl. 14:24 skrev Michael Dewey <lists using dewey.myzen.co.uk>:
> > > > >
> > > > > Dear Faradj
> > > > >
> > > > > I am afraid your post is unreadable since this is a plain text list and you sent in HTML.
> > > > >
> > > > > Michael
> > > > >
> > > > > On 03/10/2019 12:17, Faradj Koliev wrote:
> > > > >> Dear R-users,
> > > > >> I need an urgent help with the following: I have a country-year data covering the period 1982 - 2013. I want to assess how the variable X (a certain policy) affects the Y variable. The X variable is =1 when a country introduces that policy in a specific year, otherwise =0.
> > > > >> What I want to do is to create a treatment variable, that would be a negative count until the X=1, and then  positive counts  for the years after X=1.
> > > > >> For example, let’s say that the U.S. introduced the policy x in year 2000. The treatment variable would look be like this:
> > > > >>  country
> > > > >> year
> > > > >> x
> > > > >> treatment
> > > > >> USA
> > > > >> 1982
> > > > >> 0
> > > > >> -18
> > > > >> USA
> > > > >> 1983
> > > > >> 0
> > > > >> -17
> > > > >> USA
> > > > >> 1984
> > > > >> 0
> > > > >> -16
> > > > >> USA
> > > > >> 1985
> > > > >> 0
> > > > >> -15
> > > > >> USA
> > > > >> 1986
> > > > >> 0
> > > > >> -14
> > > > >> USA
> > > > >> 1987
> > > > >> 0
> > > > >> -13
> > > > >> USA
> > > > >> 1988
> > > > >> 0
> > > > >> -12
> > > > >> USA
> > > > >> 1989
> > > > >> 0
> > > > >> -11
> > > > >> USA
> > > > >> 1990
> > > > >> 0
> > > > >> -10
> > > > >> USA
> > > > >> 1991
> > > > >> 0
> > > > >> -9
> > > > >> USA
> > > > >> 1992
> > > > >> 0
> > > > >> -8
> > > > >> USA
> > > > >> 1993
> > > > >> 0
> > > > >> -7
> > > > >> USA
> > > > >> 1994
> > > > >> 0
> > > > >> -6
> > > > >> USA
> > > > >> 1995
> > > > >> 0
> > > > >> -5
> > > > >> USA
> > > > >> 1996
> > > > >> 0
> > > > >> -4
> > > > >> USA
> > > > >> 1997
> > > > >> 0
> > > > >> -3
> > > > >> USA
> > > > >> 1998
> > > > >> 0
> > > > >> -2
> > > > >> USA
> > > > >> 1999
> > > > >> 0
> > > > >> -1
> > > > >> USA
> > > > >> 2000
> > > > >> 1
> > > > >> 0
> > > > >> USA
> > > > >> 2001
> > > > >> 0
> > > > >> 1
> > > > >> USA
> > > > >> 2002
> > > > >> 0
> > > > >> 2
> > > > >> USA
> > > > >> 2003
> > > > >> 0
> > > > >> 3
> > > > >> USA
> > > > >> 2004
> > > > >> 0
> > > > >> 4
> > > > >> USA
> > > > >> 2005
> > > > >> 0
> > > > >> 5
> > > > >> USA
> > > > >> 2006
> > > > >> 0
> > > > >> 6
> > > > >> USA
> > > > >> 2007
> > > > >> 0
> > > > >> 7
> > > > >> USA
> > > > >> 2008
> > > > >> 0
> > > > >> 8
> > > > >> USA
> > > > >> 2009
> > > > >> 0
> > > > >> 9
> > > > >> USA
> > > > >> 2010
> > > > >> 0
> > > > >> 10
> > > > >> USA
> > > > >> 2011
> > > > >> 0
> > > > >> 11
> > > > >> USA
> > > > >> 2012
> > > > >> 0
> > > > >> 12
> > > > >> USA
> > > > >> 2013
> > > > >> 0
> > > > >> 13
> > > > >> Do you have any idea as how I can generate this? All suggestions are appreciated!
> > > > >> I’ve tried to create it but failed. I only could generate positive counts using this code:
> > > > >> require(data.table)
> > > > >> setDT(data)[,treatment := seq.int(0,.N-1L), by = cumsum(x)-x]
> > > > >> My sample below:
> > > > >> dput(data)
> > > > >> structure(list(country_code = c(900L, 900L, 900L, 900L, 900L,
> > > > >> 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L,
> > > > >> 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L, 900L,
> > > > >> 900L, 900L, 900L, 900L, 900L, 305L, 305L, 305L, 305L, 305L, 305L,
> > > > >> 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L,
> > > > >> 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L, 305L,
> > > > >> 305L, 305L, 305L, 305L, 140L, 140L, 140L, 140L, 140L, 140L, 140L,
> > > > >> 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L,
> > > > >> 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L, 140L,
> > > > >> 140L, 140L, 140L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L,
> > > > >> 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L,
> > > > >> 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L, 471L,
> > > > >> 471L, 471L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L,
> > > > >> 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L,
> > > > >> 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L, 352L,
> > > > >> 352L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L,
> > > > >> 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L,
> > > > >> 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L, 490L,
> > > > >> 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L,
> > > > >> 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L,
> > > > >> 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 375L, 220L,
> > > > >> 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L,
> > > > >> 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L,
> > > > >> 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 220L, 481L, 481L,
> > > > >> 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L,
> > > > >> 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L,
> > > > >> 481L, 481L, 481L, 481L, 481L, 481L, 481L, 481L, 367L, 367L, 367L,
> > > > >> 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L,
> > > > >> 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 367L, 570L, 570L,
> > > > >> 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L,
> > > > >> 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L,
> > > > >> 570L, 570L, 570L, 570L, 570L, 570L, 570L, 570L, 212L, 212L, 212L,
> > > > >> 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L,
> > > > >> 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L, 212L,
> > > > >> 212L, 212L, 212L, 212L, 212L, 212L, 212L, 359L, 359L, 359L, 359L,
> > > > >> 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L,
> > > > >> 359L, 359L, 359L, 359L, 359L, 359L, 359L, 359L, 600L, 600L, 600L,
> > > > >> 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L,
> > > > >> 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L, 600L,
> > > > >> 600L, 600L, 600L, 600L, 600L, 600L, 600L, 565L, 565L, 565L, 565L,
> > > > >> 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L,
> > > > >> 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 235L, 235L,
> > > > >> 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L,
> > > > >> 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L,
> > > > >> 235L, 235L, 235L, 235L, 235L, 235L, 235L, 235L, 317L, 317L, 317L,
> > > > >> 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L, 317L,
> > > > >> 317L, 317L, 317L, 317L, 317L, 317L, 317L, 230L, 230L, 230L, 230L,
> > > > >> 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L,
> > > > >> 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L, 230L,
> > > > >> 230L, 230L, 230L, 230L, 230L, 230L, 380L, 380L, 380L, 380L, 380L,
> > > > >> 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L,
> > > > >> 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L, 380L,
> > > > >> 380L, 380L, 380L, 380L, 380L, 640L, 640L, 640L, 640L, 640L, 640L,
> > > > >> 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L,
> > > > >> 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L, 640L,
> > > > >> 640L, 640L, 640L, 640L, 500L, 500L, 500L, 500L, 500L, 500L, 500L,
> > > > >> 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L,
> > > > >> 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L, 500L,
> > > > >> 500L, 500L, 500L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L,
> > > > >> 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L, 369L,
> > > > >> 369L, 369L, 369L, 369L, 101L, 101L, 101L, 101L, 101L, 101L, 101L,
> > > > >> 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L,
> > > > >> 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L,
> > > > >> 101L, 101L, 101L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L,
> > > > >> 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L,
> > > > >> 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L, 551L,
> > > > >> 551L, 551L), year = c(1982L, 1983L, 1984L, 1985L, 1986L, 1987L,
> > > > >> 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
> > > > >> 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
> > > > >> 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L,
> > > > >> 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L,
> > > > >> 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
> > > > >> 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
> > > > >> 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L,
> > > > >> 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
> > > > >> 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
> > > > >> 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
> > > > >> 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
> > > > >> 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
> > > > >> 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
> > > > >> 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L,
> > > > >> 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L,
> > > > >> 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L,
> > > > >> 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
> > > > >> 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L,
> > > > >> 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L,
> > > > >> 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L,
> > > > >> 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L,
> > > > >> 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L,
> > > > >> 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L,
> > > > >> 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L,
> > > > >> 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L,
> > > > >> 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
> > > > >> 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
> > > > >> 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L,
> > > > >> 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
> > > > >> 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
> > > > >> 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
> > > > >> 2011L, 2012L, 2013L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
> > > > >> 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
> > > > >> 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L,
> > > > >> 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L,
> > > > >> 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
> > > > >> 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
> > > > >> 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L,
> > > > >> 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
> > > > >> 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
> > > > >> 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
> > > > >> 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
> > > > >> 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
> > > > >> 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L,
> > > > >> 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L,
> > > > >> 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L,
> > > > >> 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
> > > > >> 2013L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
> > > > >> 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
> > > > >> 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L,
> > > > >> 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
> > > > >> 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
> > > > >> 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
> > > > >> 2011L, 2012L, 2013L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L,
> > > > >> 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L,
> > > > >> 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L,
> > > > >> 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L,
> > > > >> 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L,
> > > > >> 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L,
> > > > >> 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L,
> > > > >> 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
> > > > >> 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
> > > > >> 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1982L, 1983L,
> > > > >> 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
> > > > >> 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
> > > > >> 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
> > > > >> 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L,
> > > > >> 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
> > > > >> 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
> > > > >> 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 1991L,
> > > > >> 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
> > > > >> 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
> > > > >> 2010L, 2011L, 2012L, 2013L, 1982L, 1983L, 1984L, 1985L, 1986L,
> > > > >> 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
> > > > >> 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
> > > > >> 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
> > > > >> 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
> > > > >> 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
> > > > >> 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
> > > > >> 2009L, 2010L, 2011L, 2012L, 2013L), y = c(5.079999924, 5.079999924,
> > > > >> 5.829999924, 5.829999924, 5.829999924, 5.829999924, 5.829999924,
> > > > >> 5.829999924, 5.829999924, 5.829999924, 5.829999924, 5.829999924,
> > > > >> 9.170000076, 9.170000076, 8.159999847, 8.159999847, 8.159999847,
> > > > >> 8.159999847, 8.159999847, 8.079999924, 8.079999924, 8.079999924,
> > > > >> 8.079999924, 7.989999771, 7.989999771, 7.989999771, 7.989999771,
> > > > >> 7.989999771, 7.989999771, 7.989999771, 7.989999771, 7.989999771,
> > > > >> 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > >> 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > >> 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > >> 9.170000076, 9.170000076, 9.170000076, 9.170000076, 9.170000076,
> > > > >> 9.170000076, 9.670000076, 9.670000076, 9.670000076, 9.670000076,
> > > > >> 9.670000076, 9.670000076, 9.670000076, 9.670000076, 9.670000076,
> > > > >> 9.670000076, 9.670000076, 7.329999924, 7.329999924, 7.329999924,
> > > > >> 7.329999924, 7.329999924, 7.329999924, 4, 4, 4, 4, 4, 4, 4, 4,
> > > > >> 4, 4, 3.670000076, 3.670000076, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> > > > >> 4, 4.090000153, 4.090000153, 4.090000153, 6.489999771, 6.489999771,
> > > > >> 6.489999771, 6.489999771, 6.489999771, 6.489999771, 6.489999771,
> > > > >> 6.489999771, 6.489999771, 6.489999771, 6.739999771, 7.610000134,
> > > > >> 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > >> 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > >> 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > >> 7.610000134, 7.610000134, 7.610000134, 7.610000134, 7.610000134,
> > > > >> 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > >> 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > >> 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > >> 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > >> 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > >> 8.329999924, 8.329999924, 8.329999924, 8.329999924, 8.329999924,
> > > > >> 8.329999924, 8.329999924, 7.869999886, 7.869999886, 7.869999886,
> > > > >> 7.869999886, 7.869999886, 7.869999886, 7.869999886, 7.869999886,
> > > > >> 7.869999886, 7.869999886, 7.869999886, 7.869999886, 7.869999886,
> > > > >> 7.869999886, 7.869999886, 7.869999886, 7.869999886, 7.869999886,
> > > > >> 7.869999886, 7.869999886, 13.42000008, 13.42000008, 13.42000008,
> > > > >> 13.42000008, 13.42000008, 13.42000008, 13.42000008, 13.42000008,
> > > > >> 13.42000008, 13.42000008, 13.42000008, 13.42000008, 8, 8, 11,
> > > > >> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
> > > > >> 8.670000076, 8.670000076, 8.670000076, 8.670000076, 8.670000076,
> > > > >> 8.670000076, 8.670000076, 8.670000076, 8.670000076, 8.670000076,
> > > > >> 8.670000076, 8.670000076, 8.670000076, 9.770000458, 9.770000458,
> > > > >> 9.770000458, 9.770000458, 9.43999958, 9.43999958, 9.43999958,
> > > > >> 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958,
> > > > >> 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958, 9.43999958,
> > > > >> 9.43999958, 9.539999962, 9.539999962, 9.539999962, 9.539999962,
> > > > >> 9.539999962, 9.539999962, 9.539999962, 9.539999962, 9.539999962,
> > > > >> 9.539999962, 9.539999962, 9.539999962, 7.159999847, 7.159999847,
> > > > >> 7.159999847, 7.159999847, 7.489999771, 7.489999771, 7.489999771,
> > > > >> 7.489999771, 7.489999771, 7.489999771, 7.489999771, 7.489999771,
> > > > >> 7.489999771, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > >> 8.699999809, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > >> 8.699999809, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > >> 8.699999809, 8.699999809, 8.699999809, 8.699999809, 8.699999809,
> > > > >> 13.98999977, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > >> 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > >> 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > >> 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > >> 13.92000008, 13.92000008, 13.92000008, 6.829999924, 6.829999924,
> > > > >> 6.829999924, 6.829999924, 6.829999924, 6.829999924, 6.829999924,
> > > > >> 6.829999924, 6.829999924, 6.829999924, 11.06000042, 11.06000042,
> > > > >> 11.06000042, 11.06000042, 11.06000042, 11.06000042, 11.06000042,
> > > > >> 11.06000042, 11.06000042, 11.06000042, 11.06000042, 11.72999954,
> > > > >> 11.72999954, 11.72999954, 11.72999954, 11.72999954, 11.72999954,
> > > > >> 11.72999954, 11.72999954, 11.72999954, 11.72999954, 11.72999954,
> > > > >> 4.989999771, 4.989999771, 4.989999771, 4.989999771, 4.989999771,
> > > > >> 4.989999771, 4.989999771, 11.17000008, 11.17000008, 11.17000008,
> > > > >> 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > >> 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > >> 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > >> 11.17000008, 11.17000008, 11.17000008, 11.17000008, 11.17000008,
> > > > >> 11.17000008, 11.17000008, 14.02000046, 14.02000046, 14.02000046,
> > > > >> 14.02000046, 14.02000046, 14.02000046, 14.02000046, 14.02000046,
> > > > >> 14.02000046, 14.02000046, 14.02000046, 14.02000046, 6.920000076,
> > > > >> 6.920000076, 6.920000076, 6.920000076, 6.920000076, 6.920000076,
> > > > >> 6.920000076, 6.920000076, 6.920000076, 6.920000076, 6.920000076,
> > > > >> 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > >> 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > >> 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > >> 8.010000229, 8.010000229, 8.010000229, 8.010000229, 8.010000229,
> > > > >> 8.010000229, 10.96000004, 11.19999981, 11.19999981, 11.19999981,
> > > > >> 11.19999981, 11.19999981, 11.19999981, 11.19999981, 11.19999981,
> > > > >> 11.19999981, 11.19999981, 2.170000076, 2.170000076, 13.57999992,
> > > > >> 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > >> 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > >> 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > >> 13.57999992, 13.57999992, 13.57999992, 13.57999992, 13.57999992,
> > > > >> 13.57999992, 8.619999886, 8.619999886, 8.619999886, 8.619999886,
> > > > >> 8.619999886, 8.619999886, 8.619999886, 14.60999966, 14.60999966,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 12.42000008, 12.42000008, 12.42000008,
> > > > >> 12.42000008, 12.42000008, 12.42000008, 11.92000008, 11.92000008,
> > > > >> 11.92000008, 11.59000015, 11.31999969, 14.26000023, 14.26000023,
> > > > >> 14.26000023, 14.26000023, 14.26000023, 14.26000023, 14.26000023,
> > > > >> 14.26000023, 13.93000031, 13.93000031, 13.93000031, 13.93000031,
> > > > >> 13.93000031, 13.93000031, 14.60000038, 14.60000038, 14.60000038,
> > > > >> 14.60000038, 13.5, 13.5, 14.26000023, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 14.59000015, 14.59000015, 14.59000015, 14.59000015,
> > > > >> 14.59000015, 12.43000031, 12.43000031, 12.43000031, 12.43000031,
> > > > >> 13.15999985, 13.15999985, 13.15999985, 13.15999985, 13.15999985,
> > > > >> 13.15999985, 13.15999985, 13.15999985, 13.15999985, 13.15999985,
> > > > >> 13.15999985, 13, 13, 13.15999985, 13.15999985, 12.82999992, 12.82999992,
> > > > >> 12.82999992, 12.82999992, 12.82999992, 12.82999992, 12.82999992,
> > > > >> 12.82999992, 12.82999992, 12.82999992, 12.82999992, 12.82999992,
> > > > >> 12.82999992, 12.82999992, 12.82999992, 12.82999992, 12.82999992,
> > > > >> 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042,
> > > > >> 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042,
> > > > >> 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042, 8.31000042,
> > > > >> 8.31000042, 8.31000042, 8.31000042, 12.11999989, 12.11999989,
> > > > >> 12.11999989, 12.11999989, 12.11999989, 12.11999989, 12.11999989,
> > > > >> 12.11999989, 12.11999989, 12.11999989, 12.11999989, 2.170000076,
> > > > >> 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > >> 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > >> 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > >> 2.170000076, 2.170000076, 2.170000076, 2.170000076, 2.170000076,
> > > > >> 2.170000076, 2.170000076, 2.170000076, 7.829999924, 7.829999924,
> > > > >> 7.829999924, 7.829999924, 7.829999924, 7.829999924, 7.829999924,
> > > > >> 7.829999924, 14.23999977, 13.98999977, 13.98999977, 13.98999977,
> > > > >> 13.98999977, 13.98999977, 13.98999977, 13.98999977, 13.98999977,
> > > > >> 13.98999977, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > >> 13.92000008, 13.92000008, 13.92000008, 13.92000008, 13.92000008,
> > > > >> 13.92000008, 13.92000008, 13.92000008, 13.92000008, 6.96999979,
> > > > >> 7.46999979, 7.46999979, 7.46999979, 7.46999979, 7.46999979, 7.46999979,
> > > > >> 7.46999979, 7.46999979, 11.59000015, 11.59000015, 11.59000015,
> > > > >> 11.59000015, 11.59000015, 11.59000015, 11.59000015, 11.59000015,
> > > > >> 11.59000015, 11.59000015, 11.59000015, 15.25, 15.25, 15.25, 15.25,
> > > > >> 15.25, 15.25, 15.25, 15.25, 15.25, 15.25, 15.25, 15.25, 2.329999924,
> > > > >> 2.329999924, 2.329999924, 2.329999924, 2.329999924, 2.329999924,
> > > > >> 2.329999924, 2.329999924, 2.329999924, 2.329999924, 2.329999924,
> > > > >> 2.329999924, 4.329999924, 4.329999924, 4.329999924, 12, 12, 12,
> > > > >> 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12), x = c(0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,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0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> > > > >> 0L)), .Names = c("country_code", "year", "y", "x"), class = "data.frame", row.names = c(NA,
> > > > >> -722L))
> > > > >>      [[alternative HTML version deleted]]
> > > > >> ______________________________________________
> > > > >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > > >> https://stat.ethz.ch/mailman/listinfo/r-help
> > > > >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > > > >> and provide commented, minimal, self-contained, reproducible code.
> > > > >> ---
> > > > >> This email has been checked for viruses by AVG.
> > > > >> https://www.avg.com
> > > > >> .
> > > > >
> > > > > --
> > > > > Michael
> > > > > http://www.dewey.myzen.co.uk/home.html
> > > >
> > > >
> > > >         [[alternative HTML version deleted]]
> > > >
> > > > ______________________________________________
> > > > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > and provide commented, minimal, self-contained, reproducible code.
> > > >
> > >
> >
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help