1. Create dataset
letters <- LETTERS[1:20]
animal_names <- c("Canidae","Felidae","Cat","Cattle",
"Dog","Donkey","Goat","Guinea pig",
"Horse","Pig","Rabbit","Badger",
"Bald eagle","Bandicoot","Barnacle",
"Bass","Bat","Bear","Beaver","Bedbug",
"Bee","Beetle")2, Join the variable
plt <- ggplot(data,aes( X, Y,fill=count))
plt <- plt + geom_tile()
plt3. Plot the heatmap
data <-cbind(Treatment,made,value)
data <-data.frame(data) 4. plot heatmap
plt <- ggplot(data,aes( X, Y,fill=count))
plt <- plt + geom_tile()
plt5. Applying color
plt <- plt + theme_minimal()
plt 5. setting gradient color as red and white
plt <- plt + scale_fill_gradient(low="white", high="red")
plt5. title and sub-title
plt <- plt + labs(title = "Heatmap")
plt <- plt + labs(subtitle = "A simple heatmap using geom_tile()")
plt5. Setting x and y labels
plt <- plt + labs(x ="Alphabets", y ="Random column names")pltReference:Create Heatmap in R - GeeksforGeeks

No comments:
Post a Comment