0

I'm trying to plot every variable against every other variable with the correct axes names in separate graphs, but no plot is being created and it's not coming up with any error.

Here's the current version of my code for reference:

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))
Piomicron
  • 113
  • 4
  • I think you might simply need `....varnames[countery])) + geom_point()`. Without the `+` I'm not sure how the `geom_point()` is parsed but I don't think it will go without error. Could you run the `ggplot` lines for a specific combination of `a` and `b`? – Michael Roswell Nov 25 '19 at 21:57
  • you have to print the plot, like it is shown in the dublicate link. Also you can check [this](https://stackoverflow.com/questions/54808795/add-multiple-curves-functions-to-one-ggplot-through-looping) if you want to add curves or functions in one loop – mischva11 Nov 25 '19 at 23:16
  • @mischva11 When I go by the duplicate question I get this: "Error in .subset2(x, i) : recursive indexing failed at level 2" – Piomicron Nov 26 '19 at 20:08

0 Answers0