0

I want to filter out one factor so I can plot ggplot with the rest, I tried the following, but it did not work:

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

I also used:

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()

user432797
  • 593
  • 4
  • 13
  • 1
    Your second line `figvadc <- figvad %% c(!=Pre-clinical)` returns error. In addition, I get errors in the function `Error: Column name `Type` must not be duplicated` in the second block of code – akrun Dec 12 '20 at 22:20
  • Yes, I know @akrun, that's why I'm asking a question for help. – user432797 Dec 12 '20 at 22:22
  • My doubt is that your data already have a column named 'Type' as per the read.csv'. So, do you need to create another column 'Type' – akrun Dec 12 '20 at 22:23
  • try ```figvadc <- figvad %>% filter(Phase != Pre-clinical) ``` not sure if this is what you want to accomplish tho – Ben Dec 12 '20 at 22:24
  • 1
    Sorry @akrun I did not mean my sentence to come out with an attitude, I do appreciate your help, I wrote it asking for help, I hate it when my sentence convey a bad attitude, I apologize for the inconvenience. – user432797 Dec 12 '20 at 22:26
  • @user432797 it's okay. I was thinking that your code was used on a different data and the data showed in the github is different. Just wante to clarify. thanks for the reply – akrun Dec 12 '20 at 22:27
  • @user432797 that is not my line. It is the code I copied from your post and just to show that it is not correct – akrun Dec 12 '20 at 22:32
  • 1
    Sorry @akrun, I thought you are the only one in this conversation – user432797 Dec 12 '20 at 22:34
  • I just used your line and I get this error Error: Problem with filter()` input ..1.` @Ben – user432797 Dec 12 '20 at 22:34
  • 2
    I forgot the quotes, `figvadc <- figvad %>% filter(Phase != "Pre-clinical")` should do – Ben Dec 12 '20 at 22:36
  • It worked flawlessly @Ben thank you so much!, I just adjusted c to C – user432797 Dec 12 '20 at 22:41

0 Answers0