ggplot2 在 R 中按组拆分

ggplot2 with splitting by groups in R

我尝试在两组变量之间绘制散点图

ggplot(terr, aes(x = Killed, y = Terr..Attacks,group=Religion,Macro.Region)) +
  geom_point() +
  geom_smooth()

但我没有得到结果

如何按组创建散点图?

terr=structure(list(Macro.Region = structure(c(5L, 4L, 4L, 3L, 4L, 
6L, 1L, 2L, 4L, 3L, 6L, 5L, 4L, 4L, 3L, 4L, 6L, 1L, 2L, 4L, 3L, 
6L), .Label = c("Arab Countries", "Asia", "Eastern Europe and post-Soviet", 
"Latin America", "Sub-Saharan Africa", "Western States"), class = "factor"), 
    Killed = c(0L, 0L, 0L, 6L, 0L, 0L, 1L, 76L, 0L, 0L, 36L, 
    0L, 0L, 0L, 6L, 0L, 0L, 1L, 76L, 0L, 0L, 36L), Terr..Attacks = c(2L, 
    0L, 2L, 2L, 0L, 9L, 3L, 88L, 0L, 0L, 6L, 2L, 0L, 2L, 2L, 
    0L, 9L, 3L, 88L, 0L, 0L, 6L), Religion = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 2L, 1L, 1L, 1L), .Label = c("Christianity", "Islam"
    ), class = "factor"), GDP.capita = c(6813L, 26198L, 20677L, 
    9098L, NA, 49882L, 51846L, 4207L, 17508L, 18616L, 46301L, 
    6813L, 26198L, 20677L, 9098L, NA, 49882L, 51846L, 4207L, 
    17508L, 18616L, 46301L)), class = "data.frame", row.names = c(NA, 
-22L))
ggplot(terr, aes(x = Killed, y = Terr..Attacks)) +
  geom_point(alpha=1/4) +
  facet_wrap(Religion ~ Macro.Region)