数据框(从here借来):
abcabcbb
a is repeated 2 times
b is repeated 4 times
c is repeated 2 times
abba
a is repeated 2 times
b is repeated 2 times
uqinntq
q is repeated 2 times
n is repeated 2 times
情节:
<div>
寻求帮助: 我想将整个数据的直方图叠加到每个方面,以提供每个方面与总数据集的即时比较,如果可能的话,我希望整个数据集显示为freq_poly():
df.test <- data.frame(id = rep(1:6, each = 50), x = rnorm(50*6, mean = 10, sd = 5),
y = rnorm(50*6, mean = 20, sd = 10),
z = rnorm(50*6, mean = 30, sd = 15))
答案 0 :(得分:4)
您可以从对geom_freqpoly
的调用中排除构面变量
ggplot(df.test, aes(x)) + geom_histogram() + facet_wrap(~id) +
geom_freqpoly(data = df.test[, "x", drop = FALSE], col = "red")
答案 1 :(得分:3)