I have two dataframes:

```
df1<-data.frame(ID = c(1,1,2,3,3,4,5,6), 
           week = c(20,23,10,15,20,40,10,12), 
           var1 = rep(1, 8))
df2<-data.frame(ID=c(1,1,1,2,2,3,5),
            week = c(18,19,22,8,9,14,9),
            var1= rep(0,7))

```

I would like to combine them with the following conditions:

```
1. Keep all of df1
2. Only add the rows from df2 where the df2$week = df1$week-1

```

Output would look like this:

```
    ID week var1
1   1   19    0
2   1   20    1
3   1   22    0
4   1   23    1
5   2    9    0
6   2   10    1
7   3   14    0
8   3   15    1
9   5    9    0
10  5   10    1
11  6   12    1

```

This is a variation on a previous question asking how to keep a row on one condition and the row above it on another. I have since subset the data into two data frames, assuming it may be easier to conditionally rbind them. I tried:

```
df3<-rbind.data.frame(ifelse(df2$ID==df1$ID & df2$week==df2$week-1, df1, df2))

```

But I get an error message: 

```
longer object length is not a multiple of shorter object length. 

```

I feel like this is very close to getting the output that I want, but I am not very experienced with rbind. Thanks!