I am new to R script and need help with plotting the data. My data looks like this
run1Seek run2Seek run3Seek
1 12 23 28
2 10 27 0
3 23 19 0
4 22 24 0
5 21 26 0
6 11 26 0
I need to plot the ID value on x axis and run1Seek, run2Seek, run3Seek values on y axis. Something like this in the below image:
Try this:
library(ggplot2)
# Random data
mat <- matrix(sample(1:100, size = 1000, replace = T), ncol = 2)
colnames(mat) <- c("Run1Seek", "Run2Seek")
# Make data frame
ds <- data.frame(ID = 1:500, mat)
# Melt to long format
ds <- reshape2::melt(ds, "ID")
# Look at data
head(ds)
# Plot
ggplot(ds, aes(x = ID, y = value, fill = variable)) + geom_bar(stat = "identity")