Description Usage Arguments Value Author(s) Examples
View source: R/Supplementary_Functions.R
Heatmap_function draws heatmap in which each row is a week with horizontal bar as day of week.
1 | Heatmap_function(variable_vector, plot_title)
|
variable_vector |
Variable, in vector format, that we want to draw heatmap of weekly pattern |
date_vector |
Date variable in POSIXct format. Needs to be of the same length as the variable vector |
plot_title |
Title of the plot |
None
Jimin Lauren Yoo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (variable_vector, plot_title)
{
mod7 = length(variable_vector)%%7
end = length(variable_vector) - mod7
heatmap_dat = matrix(variable_vector[0:end], nrow = 7)
row.names(heatmap_dat) = c("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday")
heatmap_dat <- heatmap_dat[nrow(heatmap_dat):1, ]
heatmap_dat[heatmap_dat == 0] <- NA
my_palette <- colorRampPalette(c("light blue", "dark blue"))(n = 299)
heatmap(heatmap_dat, Rowv = NA, Colv = NA, col = my_palette,
srtCol = 45, main = plot_title)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.