search for: dat_long_norm

Displaying 1 result from an estimated 1 matches for "dat_long_norm".

2024 Dec 10
1
Heat maps containing two types of variables
..."month"), A=c(1,3,3,4,2,6), B=c(3,5,6,4,8,9), C=c(10,8,17,19,26,22) ) dat_long <- pivot_longer(dat,2:4,names_to="variable",values_to="value") normalize <- function(x) { y <- (x-min(x))/(max(x)-min(x)) } dat_norm <- mutate(dat,across(2:4,normalize)) dat_long_norm <- pivot_longer(dat_norm,2:4,names_to="variable",values_to="norm_value") dat_long <- inner_join(dat_long,dat_long_norm,by=c("date","variable")) heatmap <- ggplot(dat_long, aes(x = date, y = variable,fill=norm_value)) + geom_tile() + geom_text...