I am new to R and trying to determine how I can do the following:

I have 2 matrices, each row is a date and each column is a number. The second matrix is much longer than the first. I want to create a function that will multiply the first row (say its a January number) by the first 4 rows of second matrix (which are all January numbers as well). So, I'm looking for 4 results. Then I want to move to the second row of the first matrix (February number) and multiply it by the 4 February numbers from the second matrix. Eventually, I am hoping to get to the code that will multiply the first by the second if the month and years match.

First Matrix

```
Jan 2007        143.75
Feb 2007        140.93

```

Second Matrix

```
2007-01-05         12.14
2007-01-12         10.15
2007-01-19         10.40
2007-01-26         11.13
2007-02-02         10.08
2007-02-09         11.10
2007-02-16         10.02
2007-02-23         10.58

```