我的代码没有出错,但是也没有绘制

时间:2019-11-25 21:33:43

标签: r ggplot2

我正在尝试在单独的图形中针对每个具有正确轴名称的变量对其他每个变量进行绘图,但是没有创建任何绘图,并且没有出现任何错误。

以下是我的代码的最新版本:

library(tidyverse)

load("Transport_Survey.RData")

variables <- select(Transport, "InfOfReceievingWeather", "InfOfReceievingTraffic", "InfOfSeeingTraffic", "InfWeather.Ice", "InfWeather.Rain", "InfWeather.Wind", "InfWeather.Storm", "InfWeather.Snow", "InfWeather.Cold", "InfWeather.Warm", "InfWeather.DarkMorn", "InfWeather.DarkEve", "HomeParking", "WorkParking", "Disability", "Age", "CommuteFlexibility", "Gender", "PassionReduceCongest")
varnames <- list("InfOfReceivingWeather", "InfOfReceivingTraffic", "InfOfSeeingTraffic", "InfWeather.Ice", "InfWeather.Rain", "InfWeather.Wind", "InfWeather.Storm", "InfWeather.Snow", "InfWeather.Cold", "InfWeather.Warm", "InfWeather.DarkMorn", "InfWeather.DarkEve", "HomeParking", "WorkParking", "Disability", "Age", "CommuteFlexibility", "Gender", "PassionReduceCongest")

counterx = 1
countery = 1

for (a in variables) {
  for (b in variables) {
    ggplot(variables, mapping=aes(x=variables[[a]], y=variables[[b]],
    xlab=varnames[counterx], ylab=varnames[countery]))
      geom_point()
    countery = countery+1
  }
  counterx = counterx+1
}

#variables2 <- select(Transport, one_of(InfOfReceivingWeather, InfOfReceivingTraffic, InfOfSeeingTraffic, InfWeather.Ice, InfWeather.Rain, InfWeather.Wind, InfWeather.Storm, InfWeather.Snow, InfWeather.Cold, InfWeather.Warm, InfWeather.DarkMorn, InfWeather.DarkEve, HomeParking, WorkParking, Disability, Age, CommuteFlexibility, Gender, PassionReduceCongest))

0 个答案:

没有答案