Displaying 1 result from an estimated 1 matches for "dat_long".
Did you mean:
data_long
2024 Dec 10
1
Heat maps containing two types of variables
...with no success. Thanks for your help.
Philip
# REPREX
library(ggplot2)
library(tidyr)
library(dplyr)
dat <- data.frame(
date=seq.Date(as.Date("2024-01-01"),as.Date("2024-06-01"),by="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...