Search code examples
sqlrplotrodbc

Plotting data R


I have a simple tasks I would like to do. Using an RODBC connection I have connected R to a SQL server database. There are four tables in the database and they are tenors of Libor rates

Libor_1_mos
Libor_3_mos
Libor_6_mos
Libor_12_mos

Each table has two columns. The first column shows dates and the second column shows rates.

I would like a simple chart that plots the rates based on the dates in column 1. Straightforward - that is all that needs to be done. The x-axis should be dates (column 1) and the y axis should be rates (column 2). Note it is 5 years worth of data so showing every possible date on the x-axis may not be feasible.

Here is my work so far I am using the Libor_3_mos as an example

threemosdata <- sqlQuery(con,"select * from Libor_3_mos)

Using that line I can read the data from the table. So for instance

colnames(threemosdata)

will give me the names of the column in the table.


Solution

  • So this worked lovely

    > date <- (threemosdata$observation_date)
    > rates <- (threemosdata$USD3MTD156N)
    > plot(date,rates)