R 脚本图,在 x 轴上有 ID,在 ya 轴上有所有列值

R script plot with ID on xaxis and all column values on yaxis

我是 R 脚本的新手,在绘制数据方面需要帮助。 我的数据看起来像这样

  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

我需要在 x 轴上绘制 ID 值,在 y 轴上绘制 run1Seek、run2Seek、run3Seek 值。下图中的类似内容:

试试这个:

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")