Closed GoogleCodeExporter closed 8 years ago
This behaviour is as expected. NAs give an error message, while 0 are accepted
but of course show an area of size 0.
Original comment by markus.g...@googlemail.com
on 9 Aug 2011 at 7:38
Sorry I wasn't so clear. And I see you are correct when I make a small treemap
it behaves as you say. But for my large treemap, if any 0s are included in the
data.frame, it isn't that the one row with the 0 doesn't display, the entire
graphic doesn't display.
For example this code works fine:
load('d:/delete/treemap.Rdata')
t8 <- t8[t8$y2010!=0,]
ta <- gvisTreeMap(t8, idvar='id', parentvar='parent', sizevar='y2010',
colorvar='diff',
options=list(width=1200, height=800, maxDepth=1, showScale=TRUE))
plot(ta)
But if I omit the second line, I get a blank plot.
load('d:/delete/treemap.Rdata')
# t8 <- t8[t8$y2010!=0,]
ta <- gvisTreeMap(t8, idvar='id', parentvar='parent', sizevar='y2010',
colorvar='diff',
options=list(width=1200, height=800, maxDepth=1, showScale=TRUE))
plot(ta)
I hope this is useful. I find this package an excellent addition to R.
I've attached my t8 data, if you would like to try and replicate my results.
Thanks
Original comment by tomhi...@gmail.com
on 9 Aug 2011 at 8:57
Attachments:
Thanks for the data set and your lines of code.
I can replicate your problem now.
I believe the issue is caused by the Inf/-Inf values in your data set.
It appears that you calculated the relative difference without checking for
division by zero.
Hence, I tried the following with an ifelse statement, which seems to cure your
problem:
myt=t8
## recalculate the relative differences
myt$diff=with(t8, ifelse(y2009>0, (y2010/y2009 - 1)*100, NA))
p=gvisTreeMap(myt, 'id', 'parent','y2010', 'diff')
plot(p) ## displays a chart
## and I tried also
x=myt[myt$y2010!=0,]
p=gvisTreeMap(x, 'id', 'parent','y2010', 'diff')
plot(p) ## displays a chart as well
Arguably a warning could be shown if the data set includes Inf/-Inf values.
Original comment by markus.g...@googlemail.com
on 9 Aug 2011 at 12:01
Excellent! Thank you very much for the tip.
On Tue, Aug 9, 2011 at 2:02 PM,
<google-motion-charts-with-r@googlecode.com>wrote:
Original comment by tomhi...@gmail.com
on 9 Aug 2011 at 12:28
The warning section of the help file has been updated to highlight this
potential issue.
Original comment by markus.g...@googlemail.com
on 28 Aug 2011 at 6:14
Original issue reported on code.google.com by
tomhi...@gmail.com
on 5 Aug 2011 at 4:03