0

I am making a visualization that involves factors, ratios, and countries. There are about 15 factors and I am trying to use small multiples to create a large graph where the X and Y axes are the factors, ie, roughly:

Population

Num of Cars

Num of houses

               Num of Houses     Num of Cars     Population

Where each intersection would be a plot of the values for each country (so, the plot at the intersection of # of Cars and # of Houses would be # of houses vs # of cars, etc). I currently have a data frame with the information with column headers: country, factors, ratios. I've tried using a few methods (facet_grid, facet_wrap, etc), but just can't get an output - when I run the script, a blank screen pops up. I haven't been able to figure out how to successfully google the type of small multiples plot i'm trying to create and am having a bit of trouble. I'm also brand new to R and have been stuck for a great many hours.

Any advice?

Edited: More information

some sample data:

                        factor     country year     ratio  
1                           LiteracyRate Afghanistan 2000 0.3622047    
2       PostSecondarySchoolAgePopulation Afghanistan 2011 0.9272919    
3 PrePrimaryEducationSchoolAgePopulation Afghanistan 2012 0.9397506    
4    PrimaryEducationSchoolAgePopulation Afghanistan 2009 0.9344603
5           SecondarySchoolAgePopulation Afghanistan 2008 0.9301103

(I have this data for every country, and more factors than shown, also)

code that has been most successful so far:

try <-  read.table(".../temper.csv", header = TRUE, sep = ",")

remr <- ggplot(try, aes(factor, ratio)) + geom_point()

remr + facet_grid(factor ~ factor)

Graph produced: http://www.flickr.com/photos/94273266@N05/11411186776/

Henrik
  • 65,555
  • 14
  • 143
  • 159
  • 4
    People are generally much more happy to help if you provide a [**minimal, reproducible example**](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) together with the code you have tried. Thanks! – Henrik Dec 16 '13 at 22:43
  • sorry @Henrik, just added more info – user1967688 Dec 17 '13 at 00:51
  • 1
    Thanks for the example data. Sorry, but I am not entirely sure what you are looking for. To make a "grid" of plots defined by factors, you need two _different_ factors, one for the horizontal and one for the vertical direction. Have a look at [**this tutorial**](http://www.cookbook-r.com/Graphs/), especially the chapter about [**facets**](http://www.cookbook-r.com/Graphs/Facets_%28ggplot2%29/). Or perhaps you are looking for a scatter plot matrix? Then check e.g. `ggpairs` in `GGally` package. – Henrik Dec 17 '13 at 01:23
  • Ah a scatter plot matrix is the correct terminology. I wanted to have the same set of factors on both axes so that I could see correlations between ratios for two factors at a time. I was able to get a more accurate version of what i was looking for still using facets: http://www.flickr.com/photos/94273266@N05/11411801083/ ... but I can't generate the information for any factor column except Literacy Rate currently – user1967688 Dec 17 '13 at 01:31
  • Thanks for the tip for ggpairs -- i found this: http://i.stack.imgur.com/7OXSp.png which is the structure i'm looking for, so I'll investigate that more – user1967688 Dec 17 '13 at 01:33
  • Also check `pairs` in `base` R. – Henrik Dec 17 '13 at 01:34
  • You might also look at the `gridExtra` package. [See my answer here](http://stackoverflow.com/questions/20524630/modify-x-axis-labels-in-each-facet/20528655#20528655) for a step by step approach for combining several plots and still having complete control over the appearance of the sub-plots. – Jaap Dec 17 '13 at 09:59
  • the flickr is not working – Wilmer E. Henao Dec 17 '13 at 14:50

0 Answers0