我有一张如下表:
> testsizes
size value replicate lane
361 16 6898 1 L1
362 17 10707 1 L1
363 18 1786 1 L1
364 19 1721 1 L1
365 20 2454 1 L1
421 16 8486 2 L1
422 17 26691 2 L1
423 18 3241 2 L1
424 19 5068 2 L1
425 20 7579 2 L1
481 16 4152 3 L1
482 17 4452 3 L1
483 18 899 3 L1
484 19 1973 3 L1
485 20 2595 3 L1
571 16 8284 1 L2
572 17 9045 1 L2
573 18 5041 1 L2
574 19 7160 1 L2
575 20 9730 1 L2
631 16 5639 2 L2
632 17 9773 2 L2
633 18 2433 2 L2
634 19 3017 2 L2
635 20 3864 2 L2
691 16 10161 3 L2
692 17 18609 3 L2
693 18 3760 3 L2
694 19 3543 3 L2
695 20 4257 3 L2
> dput(testsizes)
structure(list(size = c(16L, 17L, 18L, 19L, 20L, 16L, 17L, 18L,
19L, 20L, 16L, 17L, 18L, 19L, 20L, 16L, 17L, 18L, 19L, 20L, 16L,
17L, 18L, 19L, 20L, 16L, 17L, 18L, 19L, 20L), value = c(6898L,
10707L, 1786L, 1721L, 2454L, 8486L, 26691L, 3241L, 5068L, 7579L,
4152L, 4452L, 899L, 1973L, 2595L, 8284L, 9045L, 5041L, 7160L,
9730L, 5639L, 9773L, 2433L, 3017L, 3864L, 10161L, 18609L, 3760L,
3543L, 4257L), replicate = c("1", "1", "1", "1", "1", "2", "2",
"2", "2", "2", "3", "3", "3", "3", "3", "1", "1", "1", "1", "1",
"2", "2", "2", "2", "2", "3", "3", "3", "3", "3"), lane = c("L1",
"L1", "L1", "L1", "L1", "L1", "L1", "L1", "L1", "L1", "L1", "L1",
"L1", "L1", "L1", "L2", "L2", "L2", "L2", "L2", "L2", "L2", "L2",
"L2", "L2", "L2", "L2", "L2", "L2", "L2")), .Names = c("size",
"value", "replicate", "lane"), row.names = c(361L, 362L, 363L,
364L, 365L, 421L, 422L, 423L, 424L, 425L, 481L, 482L, 483L, 484L,
485L, 571L, 572L, 573L, 574L, 575L, 631L, 632L, 633L, 634L, 635L,
691L, 692L, 693L, 694L, 695L), class = "data.frame")
我想使用 ggplot 制作一个线图,显示不同尺寸的值变化。目前我有这个,在我尝试过的其他组合中:
ggplot(testlengths, aes(size, value, group=replicate, colour=replicate))
+ geom_line()
看起来它试图将两条车道合并到同一个系列中。但是我找不到将车道设置为分组的另一个因素的方法。我希望根据复制和车道类别对线进行分组。泳道应该是彩色的,但复制品不需要相互区分。
我知道我可以通过预先将两组连接成一组来实现这一点。但是,在我沿着这条路线走之前,如果 ggplot 可以在没有分面的线图中按多个分组进行分组(我需要稍后使用分面进行另一个分组),我会徘徊吗?我觉得应该可以。