So I have 2 data sets in R: table 1 and table 2.
These are 2 .CSV files, with the same first column name called Date. However most of the dates are different, but some are the same.
What I would like to do is match the cells in that Date column that are identical in both tables, and then from that row where that cell is contained, i would like to return the five rows before it and the five rows after it in 10 different tables. So each row goes to a different new output table.
Basically I would like to run a regression on each ith row table afterwards, with some other column in that table..
I was thinking using head() and tail() but i couldnt figure out the index part to where to start..
thank you. this is a simple example. when match row 3 in table 1 with row 1 in table 2, how would i go about taking the 3 rows in table 1 below that matched row.
>table 1
>Date price1 price2 price3
>11/02/13 4.4 4.22 4.12
>11/04/13 4.23 4.09 4.10
>12/01/13 4.01 4.27 4.14
>12/02/13 4.1 4.23 4.16
>12/02/13 4.65 4.23 4.17
>11/01/13 4.4 4.22 4.12
>11/07/13 4.23 4.09 4.10
>12/09/13 4.01 4.27 4.14
>12/12/13 4.1 4.23 4.16
>12/15/13 4.65 4.23 4.17
>table 2
>Date price1 price2 price3
>12/01/13 2.4 2.22 9.12
>08/04/13 4.23 7.09 6.10
>12/01/13 1.01 6.27 6.14
>12/08/13 6.1 3.23 4.16
>12/05/13 4.65 2.23 3.17
>11/02/13 4.4 4.22 4.12
>07/04/13 4.23 4.09 4.10
>09/01/13 4.01 4.27 4.14
>01/02/13 4.1 4.23 4.16
>11/05/13 4.65 4.23 4.17