R 创建堆叠条形图,其中某些列为';填充&x27;参数和行摘要为';x';论点

R 创建堆叠条形图,其中某些列为';填充&x27;参数和行摘要为';x';论点,r,ggplot2,R,Ggplot2,我有下面的框架: Target_Category<-c("Adhesion","Cytochrome") Validated<-c(5,10) Candidate<-c(7,8) dataf<-data.frame(Target_Category,Validated,Candidate) 在打印之前,您需要重塑数据集: library(tidyverse) Target_Category<-c("Adhesion","Cytochrome") Validated

我有下面的框架:

Target_Category<-c("Adhesion","Cytochrome")
Validated<-c(5,10)
Candidate<-c(7,8)
dataf<-data.frame(Target_Category,Validated,Candidate)

在打印之前,您需要重塑数据集:

library(tidyverse)

Target_Category<-c("Adhesion","Cytochrome")
Validated<-c(5,10)
Candidate<-c(7,8)
dataf<-data.frame(Target_Category,Validated,Candidate)

dataf %>%
  gather(col, value, -Target_Category) %>%
  ggplot() + 
  geom_bar(aes(Target_Category, value, fill = col), stat="identity")
库(tidyverse)
目标类别
library(tidyverse)

Target_Category<-c("Adhesion","Cytochrome")
Validated<-c(5,10)
Candidate<-c(7,8)
dataf<-data.frame(Target_Category,Validated,Candidate)

dataf %>%
  gather(col, value, -Target_Category) %>%
  ggplot() + 
  geom_bar(aes(Target_Category, value, fill = col), stat="identity")