【发布时间】:2019-11-12 16:58:44
【问题描述】:
我开始了
>df57 <- data.frame(cellType = c("4.57", "4.57", "8.57", "8.57", "8.28.57", "8.28.57"),
ORR = c("PD", "nonPD"),
BL = rep(0, each=6),
Treated = c(10, -5, 8, -4, 15, -2))
>df57melt <- melt(df57)
>df57melt
cellType ORR variable value
1 4.57 PD BL 0
2 4.57 nonPD BL 0
3 8.57 PD BL 0
4 8.57 nonPD BL 0
5 8.28.57 PD BL 0
6 8.28.57 nonPD BL 0
7 4.57 PD Treated 10
8 4.57 nonPD Treated -5
9 8.57 PD Treated 8
10 8.57 nonPD Treated -4
11 8.28.57 PD Treated 15
12 8.28.57 nonPD Treated -2
我想制作一个线图,其中治疗在 x 轴上(BL,Treated),值在 y 轴上(连续)。我想要三种细胞类型(4.57、8.57 和 8.28.57;我想用线条颜色编码),每种都有响应变量(PD 和 nonPD;我想用线条样式编码)。
我绘制了我认为应该起作用的东西:
>ggplot(data=df57melt, aes(x=variable, y = value)) +
geom_line(aes(linetype = ORR, color = cellType))
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
#so I add group info
>ggplot(data=df57melt, aes(x=variable, y = value, group = cellType)) +
geom_line(aes(linetype = ORR, color = cellType))
Error: geom_path: If you are using dotted or dashed lines, colour, size and linetype must be constant over the line
#but if I change from categorical x to continuous x...
>ggplot(data=df57melt, aes(x=as.numeric(variable), y = value)) +
geom_line(aes(linetype = ORR, color = cellType))
【问题讨论】: