Skip to content

Instantly share code, notes, and snippets.

@actongorton
Last active August 29, 2015 14:19
Show Gist options
  • Save actongorton/6592233b694dc96d46e4 to your computer and use it in GitHub Desktop.
Save actongorton/6592233b694dc96d46e4 to your computer and use it in GitHub Desktop.
Create a Calendar Heatmap using R with the GoogleVis Library
# ###
# Original credit: http://www.r-bloggers.com/calendar-charts-with-googlevis/
# ###
#
# load the csv as a dataframe:
insp_data <- read.csv(insp_avg_scores.csv, as.is=TRUE)
#
# create dates (evaluate the data to find the earliest date)
start.date = "2012-11-19"
end.date = end.date <- Sys.Date()
#
# convert the column in the insp_data dataframe from string to date
insp_avg_scores$insp_date <- as.Date(insp_avg_scores$insp_date, "%m/%d/%Y")
#
# load data into plot for vis:
plot(
gvisCalendar(
data=insp_avg_scores,
datevar="insp_date",
numvar="average_score",
options=list(
title="Average Inspection Scores by Date",
calendar="{cellSize:10, yearLabel:{fontSize:20, color:'#444444'},
focusedCellColor:{stroke:'red'}}",
width=590,
height=900
),
chartid="Calendar"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment