Hi,
I am trying to create a heatmap by using ggplot but when I try to indicate the min and max values of my data, R automatically modifes the values.
I show you what I have done:
My data:
Showing 1 to 14 of 22 entries
library(ggplot2)
library(reshape2)
## transform data
heatmap_data_2 = melt(heatmap_data)
this is heatmap_data_2
##scale colors
heatmap_data_3 <- expand.grid(ID = heatmap_data_2$ID, variable = heatmap_data_3$variable)
heatmap_data_3$value <- runif(nrow(heatmap_data_3), min = 0, max = 6)
the problem now is that r modifies my data: this is now
I am sure it is an stupid thing but I don't know what the problem is.
Any help would be more than welcome :)
Similar problem: Problem in running R-code
Because you are generating random data -
runif
.I think you will need merge, something like
res <- merge(heatmap_data_2, heatmap_data_3, by = c("ID", "variable"))
or usedplyr::complete
function.