在多个变量之间创建散点图

时间:2019-11-06 14:13:50

标签: r

flavanoidsphenols之间创建散点图。使点的颜色和形状反映出葡萄酒的来源。

给定:

wineurl <- paste("https://archive.ics.uci.edu/ml/",
             "machine-learning-databases/wine/wine.data", sep = "")
wine <- as_tibble(read.csv(file = wineurl, header = FALSE))
colnames(wine) <- c("origin", "alcohol", "acid", 
                       "ash", "alcalinity", "magnesium", 
                       "phenols", "flavanoids", "nonflavanoid",
                       "proanthocyanins","color.int", "hue",
                       "od", "proline")

wine <- wine %>% 
  mutate(origin = factor(origin))

1 个答案:

答案 0 :(得分:0)

尝试ggplot(wine, aes(x = flavanoids, y = phenols, col=origin)) + geom_point()

ggplot()告诉R进行酚对黄酮的绘图,并对不同的来源使用不同的颜色。 geom_point()告诉R做一个散点图。