首页 > 解决方案 > 如何使用 ggplot() 导出 R 中变量之间的关系

问题描述

我试图通过下面的代码确定变量“RainTomorrow”与其他变量之间的关系。但是,似乎我编码的方式并没有给我输出。如何确定 RainTomorrow 和所有其他变量的关系?

rattle::weatherAUS  # to load the dataset into R

str(weather)
weather$Date <- as.Date(weather$Date)
weather$RainTomorrow <- as.factor(weather$RainTomorrow)

# exploring all the varibales
weather %>%
  keep(is.numeric) %>% 
  gather() %>% 
  ggplot(aes(value)) +
  facet_wrap(~ key, scales = "free") +
  geom_histogram()

标签: rggplot2histogram

解决方案


rattle::weatherAUS仅将数据打印到控制台。你需要跑weather <- rattle::weatherAUS

之后,一切都会正常工作。


推荐阅读