2017-10-16 56 views
-1

所以我有一个非常复杂的(至少对我来说这是哈哈)ggplot,我试图从这些数据创建。ggplot从这张表中堆积的条形图

Issue = c("Difficulty receiving products in general", 
"Supplier compliance issues", "Supplier fraud, waste, or abuse", 
"Difficulty receiving products in general", "Difficulty receiving products in general", 
"Supplier fraud, waste, or abuse", "Supplier service issues", 
"Problems repairing due to service issues ", "Problems repairing due to service issues ", 
"Other", "Billing, coverage, coordination of benefits", "Problems repairing due to service issues ", 
"Difficulty receiving products in general", "Difficulty receiving products in general", 
"Low quantity/quality", "Difficulty receiving products in general", 
"Difficulty receiving products in general", "Supplier service issues", 
"Problems repairing due to service issues ", "Problems repairing due to service issues ", 
"Problems repairing due to service issues ", "Problems repairing due to lack of inventory ", 
"Supplier service issues", "Difficulty receiving products in general", 
"Supplier service issues") 

Resolution = c("Current supplier resolved the issue", 
"Current supplier resolved the issue", "Current supplier resolved the issue", 
"Supplier educated about inquiry\n", "Beneficiary educated about inquiry ", 
"Supplier educated about inquiry\n", "Beneficiary educated about DMEPOS\n", 
"Beneficiary educated about inquiry ", "Beneficiary educated about inquiry ", 
"Beneficiary educated about inquiry ", "Beneficiary educated about suppliers", 
"The case unresolved ", "The case unresolved ", "Beneficiary educated about DMEPOS\n", 
"Current supplier resolved the issue", "Current supplier resolved the issue", 
"Beneficiary educated about DMEPOS\n", "Beneficiary educated about suppliers", 
"New supplier found ", "Beneficiary educated about suppliers", 
"Supplier educated about inquiry\n", "New supplier found ", 
"New supplier found ", "Beneficiary educated about DMEPOS\n", 
"The case unresolved ") 

df <- data.frame(Issue,Resolution) 
crosstable<- table(df$Issue,df$Resolution) 

我想创建一个具有在X轴上问题堆积条形图ggplot,然后在y轴数,也显示了每个问题是如何通过决议进行细分。这在Excel中很容易做到,但是由于我在R中制作其他图表,我希望保持美观一致。

+0

你到目前为止尝试过什么? – Mako212

+1

你有没有尝试过任何'ggplot()'代码?看起来像一个编码服务请求,而不是一个特定的问题 – Nate

回答

1

尝试:

ggplot(df, aes(Issue, fill = Resolution)) + geom_bar() 

如果不是订单,只需切换问题和解决的位置。