【发布时间】:2020-06-27 20:02:58
【问题描述】:
structure(list(Generation = c(1, 2, 3, 4), Type = structure(c(1L,
1L, 1L, 1L), .Label = c("Mean_1", "Mean_16", "Mean_4", "Mean_64",
"Mean_F"), class = "factor"), Heterozygosity = c(0.983622406756008,
0.984560911429398, 0.984607962819721, 0.983946353837307)), row.names = c(NA,
-4L), class = c("tbl_df", "tbl", "data.frame"))
所以我有一个具有上述结构的数据框,如下所示:
# A tibble: 6 x 3
Generation Type Heterozygosity
<dbl> <fct> <dbl>
1 1 Mean_1 0.984
2 2 Mean_1 0.985
3 3 Mean_1 0.985
4 4 Mean_1 0.984
5 5 Mean_1 0.983
6 6 Mean_1 0.983
我正在尝试使用以下代码绘制折线图:
ggplot(LongRed, aes(x = Generations, y = Heterozygosity)) +
geom_line(aes(color = Type))
它给了我错误:
Error: Aesthetics must be either length 1 or the same as the data (2190): x
我该怎么办?
【问题讨论】:
-
您的栏目名称是“世代”。如果我把它改成那个,它对我来说可以很好地处理 dput 数据
标签: r dataframe ggplot2 graph analysis