r - Cross table graph similar to excel -


i need put 3d kind of graph similar attached image created in excel. not sure whether can in ggplot?

cross table image

structure(list(name = c("a", "b", "c", "d"), p = c(15089, na,  na, 43083), q = c(1589, na, na, 18120), r = c(93751, na, 4709,  211649), s = c(34167, 1323, 1520, 82378), t = c(8831, na, 4544,  15157)), .names = c("name", "p", "q", "r", "s", "t"), row.names = c(na,  4l), class = "data.frame") 

i have worked following code.

ggplot(a, aes(x = a$a, y = a$amount, fill = a$b)) +  geom_col(position = 'stack') +  geom_text(aes(label = a$amount), position = position_stack(vjust = .5),       color='grey25', size=2) + coord_flip()  

the problem labels shows on top the graph overlapping

updated: actually, thought need reshape data achieve kind of graph, not sure though. reshaped below

structure(list(aa = c("a", "a", "a", "a", "a", "b", "b", "b",  "b", "b", "c", "c", "c", "c", "c", "d", "d", "d", "d", "d"),      bb = c("p", "q", "r", "s", "t", "p", "q", "r", "s", "t",      "p", "q", "r", "s", "t", "p", "q", "r", "s", "t"), amount = c(15089,      1589, 93751, 34167, 8831, na, na, na, 1323, na, na, na, 4709,      1520, 4544, 43083, 18120, 211649, 82378, 15157)), .names = c("aa",  "bb", "amount"), row.names = c(na, 20l), class = "data.frame") 

i tried following code achieve labels overlapping

ggplot(a, aes(x = aa, y = amount, fill = bb)) +      geom_col(position = 'stack')+     geom_text(aes(label = amount),               position = position_stack(vjust = 0.2),                color='grey25',                size=2) +     coord_flip() 

also, when supply ggploty shiny, graph not coming in dashboard


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -