우선 아래와 같이
시간(Timestamp), 날짜(Date), 순서(Seq) 변수를 생성한다.
dt <- dt %>%
dplyr::mutate(Timestamp = as.POSIXct(Timestamp, format = "%Y-%m-%d %H:%M:%S")) %>%
dplyr::mutate(Date = substr(Timestamp, 1, 10)) %>%
dplyr::arrange(Timestamp) %>%
dplyr::mutate(Seq = 1:nrow(.))
해당 변수를 이용해 x축을 아래와 같이 넣는다.
Date.info <- which(unlist(sapply(rle(dt$Date)$lengths, seq)) == 1)
Date.label <- sort(unique(dt$Date), decreasing = FALSE)
plot(Data_value ~ Seq, data = dt)
axis(1, # bottom (x축)
at = Date.info,
labels = Date.label,
las = 2, # 세로로 axis 표기
cex.axis = 0.8 # 확대율
)