Skip to content

Instantly share code, notes, and snippets.

@mages
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save mages/9709148 to your computer and use it in GitHub Desktop.

Select an option

Save mages/9709148 to your computer and use it in GitHub Desktop.

Revisions

  1. mages revised this gist Mar 23, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # See also the entry on stackoverflow: http://goo.gl/KUvmW2
    library(lattice)
    library(chron)
    source("http://blog.revolutionanalytics.com/downloads/calendarHeat.R")
  2. mages revised this gist Mar 22, 2014. 1 changed file with 0 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,3 @@
    stock <- "MSFT"
    start.date <- "2012-01-01"
    end.date <- Sys.Date()
    quote <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
    stock,
    "&a=", substr(start.date,6,7),
    "&b=", substr(start.date, 9, 10),
    "&c=", substr(start.date, 1,4),
    "&d=", substr(end.date,6,7),
    "&e=", substr(end.date, 9, 10),
    "&f=", substr(end.date, 1,4),
    "&g=d&ignore=.csv", sep="")
    stock.data <- read.csv(quote, as.is=TRUE)
    library(lattice)
    library(chron)
    source("http://blog.revolutionanalytics.com/downloads/calendarHeat.R")
  3. mages revised this gist Mar 22, 2014. 1 changed file with 1 addition and 15 deletions.
    16 changes: 1 addition & 15 deletions CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -16,18 +16,4 @@ library(chron)
    source("http://blog.revolutionanalytics.com/downloads/calendarHeat.R")
    # Plot as calendar heatmap
    calendarHeat(stock.data$Date, stock.data$Adj.Close,
    varname="MSFT Adjusted Close")

    library(googleVis)
    stock.data$Date <- as.Date(stock.data$Date)
    plot(
    gvisCalendar(data=stock.data, datevar="Date", numvar="Adj.Close",
    options=list(
    title="Calendar heat map for MSFT adjsuted close",
    calendar="{ cellSize: 10,
    yearLabel: { color: '#444444'},
    focusedCellColor: {stroke:'red'}}",
    width=590, height=320),
    chartid="Calendar")
    )

    varname="MSFT Adjusted Close")
  4. mages revised this gist Mar 22, 2014. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -22,8 +22,12 @@ library(googleVis)
    stock.data$Date <- as.Date(stock.data$Date)
    plot(
    gvisCalendar(data=stock.data, datevar="Date", numvar="Adj.Close",
    options=list(calendar="{ cellSize: 10 }",
    width=590, height=320),
    options=list(
    title="Calendar heat map for MSFT adjsuted close",
    calendar="{ cellSize: 10,
    yearLabel: { color: '#444444'},
    focusedCellColor: {stroke:'red'}}",
    width=590, height=320),
    chartid="Calendar")
    )

  5. mages revised this gist Mar 22, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,8 @@ quote <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
    "&f=", substr(end.date, 1,4),
    "&g=d&ignore=.csv", sep="")
    stock.data <- read.csv(quote, as.is=TRUE)

    library(lattice)
    library(chron)
    source("http://blog.revolutionanalytics.com/downloads/calendarHeat.R")
    # Plot as calendar heatmap
    calendarHeat(stock.data$Date, stock.data$Adj.Close,
  6. mages revised this gist Mar 22, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -17,9 +17,8 @@ source("http://blog.revolutionanalytics.com/downloads/calendarHeat.R")
    calendarHeat(stock.data$Date, stock.data$Adj.Close,
    varname="MSFT Adjusted Close")

    stock.data$Date <- as.Date(stock.data$Date)

    library(googleVis)
    stock.data$Date <- as.Date(stock.data$Date)
    plot(
    gvisCalendar(data=stock.data, datevar="Date", numvar="Adj.Close",
    options=list(calendar="{ cellSize: 10 }",
  7. mages created this gist Mar 22, 2014.
    29 changes: 29 additions & 0 deletions CalendarChart.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    stock <- "MSFT"
    start.date <- "2012-01-01"
    end.date <- Sys.Date()
    quote <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
    stock,
    "&a=", substr(start.date,6,7),
    "&b=", substr(start.date, 9, 10),
    "&c=", substr(start.date, 1,4),
    "&d=", substr(end.date,6,7),
    "&e=", substr(end.date, 9, 10),
    "&f=", substr(end.date, 1,4),
    "&g=d&ignore=.csv", sep="")
    stock.data <- read.csv(quote, as.is=TRUE)

    source("http://blog.revolutionanalytics.com/downloads/calendarHeat.R")
    # Plot as calendar heatmap
    calendarHeat(stock.data$Date, stock.data$Adj.Close,
    varname="MSFT Adjusted Close")

    stock.data$Date <- as.Date(stock.data$Date)

    library(googleVis)
    plot(
    gvisCalendar(data=stock.data, datevar="Date", numvar="Adj.Close",
    options=list(calendar="{ cellSize: 10 }",
    width=590, height=320),
    chartid="Calendar")
    )