假设我有
'data.frame': 75 obs. of 4 variables:
$ study : chr "Dux" "Steele" "Ness" "Dux" ...
$ celltype : chr "Lymph" "Granulo" "Lymph" "Lymph" ...
$ value : int NA NA 86 NA NA NA NA NA 76 100 ...
$ time.numeric: num 4 5 0.5 6 4 2 3 24 1.5 0.5 ...
我的目标是通过一个geom_smooth()
连接所有geom_point()
,当由于NA
而出现中断时也是如此。为什么geom_smooth()
不连接所有geom_points()
?尽管在所有方面都存在多个geom_points()
,但它似乎只适用于一些facet_wraps
a <– structure(list(study = c("Milnari", "Rajesh", "Steele", "de Graaf",
"Chow_RT", "Steele", "Milnari", "Dux", "de Graaf", "Basile_Bcell",
"Steele", "de Graaf", "Renshaw", "Renshaw", "Milnari", "Rajesh",
"Steele", "Rajesh", "Rajesh", "Dux", "Ness", "Basile_Tcell",
"Rajesh", "de Graaf", "Milnari", "Dux", "Ness", "de Graaf", "de Graaf",
"Rajesh", "Rajesh", "Chow_RT", "Steele", "de Graaf", "Milnari",
"Ness", "Dux", "Dux", "Ness", "Basile_Bcell", "Dux", "Milnari",
"Renshaw", "Basile_Bcell", "Steele", "Renshaw", "Rajesh", "Rajesh",
"Milnari", "de Graaf"), celltype = c("Lymph", "Granulo", "Granulo",
"Mono", "WBC", "Mono", "Lymph", "Lymph", "Lymph", "Lymph", "Granulo",
"Granulo", "WBC", "WBC", "Lymph", "WBC", "Lymph", "Granulo",
"Granulo", "Granulo", "Lymph", "Lymph", "Granulo", "Mono", "Lymph",
"Granulo", "Lymph", "Mono", "Granulo", "WBC", "WBC", "WBC", "Granulo",
"Lymph", "Granulo", "Lymph", "Lymph", "Lymph", "Lymph", "Lymph",
"Lymph", "Lymph", "WBC", "Lymph", "Granulo", "WBC", "WBC", "Granulo",
"Granulo", "Granulo"), value = c(93L, 81L, 50L, NA, NA, NA, NA,
88L, NA, NA, 42L, NA, 6L, NA, 93L, NA, 69L, 100L, NA, 25L, NA,
85L, 70L, NA, NA, 10L, 80L, NA, NA, NA, 80L, 85L, NA, NA, NA,
NA, NA, NA, NA, 75L, NA, NA, NA, NA, 48L, 30L, NA, NA, NA, 58L
), time.numeric = c(1.5, 2, 2, 4, 48, 5, 2, 0.5, 4, 2, 4, 4,
48, 4, 1, 6, 3, 0.5, 1, 1, 24, 24, 4, 6, 48, 1.5, 1, 48, 6, 3,
2, 1, 1.5, 2, 5, 2, 2, 5, 6, 24, 48, 2, 2, 4, 3, 24, 24, 3, 6,
5)), class = "data.frame", row.names = c(NA, -50L))
我的尝试:
ggplot(a, aes(x = time.numeric, y = value,
color = study, fill = study)) +
geom_point() +
scale_x_continuous(trans = "log2") +
facet_wrap(~ celltype) +
geom_smooth(se = FALSE)
我似乎收到了一个warning()
,但我不能将其与问题联系起来。
> warnings()
Warning messages:
1: Removed 46 rows containing non-finite values (stat_smooth).
2: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
span too small. fewer data values than degrees of freedom.
3: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
pseudoinverse used at -1.0079
1条答案
按热度按时间eaf3rand1#
根据Jon Spring的建议,解决方案是
geom_path()
,之前删除了NA