Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. library(plotly)
  2.  
  3. # Create some fake data - say ownership and land use data with acreage
  4. df <- data.frame(ownership=c(rep("private", 3), rep("public",3),rep("mixed", 3)),
  5. landuse=c(rep(c("residential", "recreation", "commercial"),3)),
  6. acres=c(108,143,102, 300,320,500, 37,58,90))
  7.  
  8. # Just try some quick pie charts of acreage by landuse and ownership
  9. plot_ly(data=df, labels= ~landuse, values= ~acres, type='pie')
  10. plot_ly(data=df, labels= ~ownership, values= ~acres, type='pie')
  11.  
  12. # This doesn't render anything... not that I'd expect it to given the data format doesn't seem to match what's needed,
  13. # but this is what I'd intuitively expect to work..
  14. plot_ly(data=df, labels= ~landuse, parents = ~ownership, values= ~acres, type='sunburst')
  15.  
  16. # Is there an easy way to go from the dataframe, df, to hierarchical format needed for sunburst?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement