library(tidyverse)
library(lubridate)
library(gplots)
library(RColorBrewer)
# 데이터 가정
data.frame(tt='2010-01-01 00:00:00', power.consumption=99) %>%
rbind(data.frame(tt='2010-01-01 00:15:00', power.consumption=100)) %>%
rbind(data.frame(tt='2010-01-01 00:30:00', power.consumption=130)) %>%
rbind(data.frame(tt='2010-01-02 00:00:00', power.consumption=100)) %>%
rbind(data.frame(tt='2010-01-02 00:15:00', power.consumption=110)) %>%
rbind(data.frame(tt='2010-01-02 00:30:00', power.consumption=120)) %>%
rbind(data.frame(tt='2010-01-08 00:00:00', power.consumption=80)) %>%
rbind(data.frame(tt='2010-01-08 00:15:00', power.consumption=105)) %>%
rbind(data.frame(tt='2010-01-08 00:30:00', power.consumption=120)) -> temp
#요일 시간대 평균으로 처리
temp %>%
mutate(wd=wday(tt,label=T,abbr=F)) %>%
mutate(hhmm=str_sub(tt,12,16)) %>%
group_by(wd,hhmm) %>%
summarize(power.consumption=mean(power.consumption)) %>%
pivot_wider(names_from = hhmm,
values_from = power.consumption,
values_fill =0) %>%
ungroup() %>%
column_to_rownames(var = "wd") %>%
as.matrix() %>%
heatmap.2(col=brewer.pal(9,"Blues"),
dend="none",trace="none",key=FALSE,
margins=c(10,7),
cexRow=1.5,cexCol=1.2,
colRow=c("green4","maroon"),
main="Title Heare")
'ADP (R)' 카테고리의 다른 글
ADP 실기 26회 후기(문제 포함) (0) | 2022.09.25 |
---|---|
오늘의 ADP 준비 / 2022-09-24 토 (2) | 2022.09.24 |
오늘의 ADP 준비 / 2022-09-20 화(D5) (2) | 2022.09.20 |
[R] plot las=1 (2) | 2022.09.19 |
[R] plot type="b" (2) | 2022.09.19 |