leeper / slopegraph

Edward Tufte-Inspired Slopegraphs
187 stars 21 forks source link

Problem when saving as PDF #7

Closed leeper closed 8 years ago

leeper commented 9 years ago

Bug report via email:

Here's a data frame of state polarization by 4 year intervals. When I enter the following interactively, I get the slopegraph in the Rstudio plot window.

slopegraph(na.omit(sg), col.line='gray',decimals=1,labels=c('1996','2000','2004','2008','2014'), binval=1.5)

BTW, the slopegraph doesn't work unless I omit NAs but this isn't quite what I want as I lose the entire set of observations if a state has any missing values. (see also #3)

The big question though is why I get a strange error when I set up the pdf:

pdf('Plots/Legislatures_2016/States/polarization_slopegraph.pdf', height=16, width=12, family='Palatino')
slopegraph(na.omit(sg), col.line='gray',decimals=1,labels=c('1996','2000','2004','2008','2014'), binval=1.5)

The error I get from just adding the pdf command at the top is:

Error in `row.names<-.data.frame`(`*tmp*`, value = value) : 
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘0.4’ 

I don't understand why row names would be set at one of the values? It should be state abbreviations!

leeper commented 9 years ago

I think this should be fixed by https://github.com/leeper/slopegraph/commit/f3d204efdf43ecb77be86ed76d3c11d8ae25c27d. The issue appeared to be related to the internal overlaps function, which is device-dependent.