首页 > 解决方案 > 如何过滤掉R中的一个因素

问题描述

我想过滤掉一个因素,以便可以将 ggplot 与其余因素一起绘制,我尝试了以下方法,但没有奏效:

library(ggplot2)
figvad <- read.csv(url("https://raw.githubusercontent.com/learnseq/learning/main/vadev.txt"),sep = '\t',header = TRUE)
figvadc <- figvad %% c(!=Pre-clinical)

我也用过:

library(tidyverse)
library(ggplot2)
figvad <- read.csv(url("https://raw.githubusercontent.com/learnseq/learning/main/vadev.txt"),sep = '\t',header = TRUE)
figvadclinic<-figvad %>% 
  rownames_to_column("Type") %>% 
  filter(stringr::str_detect(type, 'Pre-clinical') )
library(repr, warn.conflicts = FALSE)
options(repr.plot.width=17, repr.plot.height=10)

ggplot(figvadclinic, aes(x=Phase, fill=Type)) + 
  geom_bar(width = 0.5) +
  coord_polar()+
theme(panel.grid.major = element_blank(), element_text(size=25, face=4L))+
theme_minimal()

标签: rggplot2

解决方案


推荐阅读