위의 막대 그래프 막대 위에 각 변수에 대한 관측 수를 추가하고 싶습니다. 여기 내 데이터 프레임입니다.ggplot을 사용하여 막대 그래프의 막대 그래프 관측 번호
means <- structure(list(Driver = c("Crop agriculture", "Crop agriculture",
"Infrastructure", "Infrastructure", "Mining", "Mining", "Mixed Agriculture",
"Mixed Agriculture", "Other land use", "Other land use", "Pasture",
"Pasture", "Tree crops", "Tree crops", "Water", "Water"), Period = c("1990-2000",
"2000-2005", "1990-2000", "2000-2005", "1990-2000", "2000-2005",
"1990-2000", "2000-2005", "1990-2000", "2000-2005", "1990-2000",
"2000-2005", "1990-2000", "2000-2005", "1990-2000", "2000-2005"
), mean = c(36.2697273704497, 61.3311804191792, 28.7523209391483,
30.955220240622, 49.4900570536558, 41.5037095947389, 13.1454310847706,
10.3642833385884, 28.5871996967629, 23.3988064930454, 53.9768942854543,
61.3460606144189, 17.326, 16.1278503954073, 36.6165841628849,
32.6896740558384), n = c("n = 1669", "n = 783", "n = 298", "n = 151",
"n = 20", "n = 7", "n = 1355", "n = 925", "n = 1623", "n = 851",
"n = 10986", "n = 6039", "n = 316", "n = 211", "n = 466", "n = 244"
)), .Names = c("Driver", "Period", "mean", "n"), class = "data.frame", row.names = c(NA,
-16L))
이 데이터 프레임을 기반으로하고 싶은 점은 무엇입니까?
means.barplot <- ggplot(means, aes(x = Driver, y = mean, fill = Period, width = .85)) +
geom_bar(position = "dodge", stat = "identity") +
labs(x = "", y = "EF (T/ha)") +
theme(axis.text = element_text(size = 16),
axis.title = element_text(size = 20),
legend.title = element_text(size = 20, face = "bold"),
legend.text = element_text(size = 20),
axis.line = element_line(colour = "black")) +
scale_fill_grey("Period") +
scale_y_continuous(limits = c(0, 70)) +
theme_classic(base_size = 20, base_family = "") +
theme(panel.grid.minor = element_line(colour =" grey", size = 0.5))
그러나이 플롯에는 각 변수 (이 경우 각 기간의 드라이버)에 대한 관측자 수를 더하고 싶습니다. 아직 그 일을 처리하지 못했습니다. 누군가 나를 도와 줄 수 있습니까? 감사.