Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
按R中的组进行拆分的ggplot2_R_Ggplot2_Gplots - Fatal编程技术网

按R中的组进行拆分的ggplot2

按R中的组进行拆分的ggplot2,r,ggplot2,gplots,R,Ggplot2,Gplots,我试着在两组变量之间进行散点图 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, 4

我试着在两组变量之间进行散点图

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))

你说的团体是什么意思?每组的形状和/或颜色也不同。外面有很多。简单谷歌帮助。顺便说一句,如果是两组,试试互动(x,y)
ggplot(terr, aes(x = Killed, y = Terr..Attacks)) +
  geom_point(alpha=1/4) +
  facet_wrap(Religion ~ Macro.Region)