我有一个数据框如下:
GR CYT EMT PRO
High 8 5 8
Low 8 2 2
High 6 2 10
High 5 7 4
Low 7 2 1
Low 5 10 4
High 6 3 5
Low 8 1 10
High 4 7 5
High 2 3 8
Low 3 2 7
Low 5 7 1
High 7 7 2
High 5 1 3
我想使用 R 绘制图中的所有参数。我想检查三个参数 CYT、EMT、PRO 与 GR 的关系。
df <- data.frame(
GR = c("High", "Low", "High", "High", "Low", "Low", "High", "Low", "High", "High", "Low", "Low", "High", "High"),
CYT = c(8, 8, 6, 5, 7, 5, 6, 8, 4, 2, 3, 5, 7, 5),
EMT = c(5, 2, 2, 7, 2, 10, 3, 1, 7, 3, 2, 7, 7, 1),
PRO = c(8, 2, 10, 4, 1, 4, 5, 10, 5, 8, 7, 1, 7, 3)
)
我尝试过类似以下的方法:
# Melt the data to long format for better plotting
df_long <- reshape2::melt(df, id.vars = "GR")
# Create a grouped bar plot
ggplot(df_long, aes(x = variable, y = value, fill = GR)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Relationship of Parameters with GR",
x = "Parameter",
y = "Value") +
theme_minimal()
还有其他方式来表示数据吗?