Is there a way I can extract specific rows that contain a certain word in a column?

I am new to R and wondering how I would extract all rows that contain "missense_variant" in column "ANN[0].EFFECT"

Thank you!

Hi Researcher001,

It seems you are very new to R and I would recommend completing a course such as this: R for Excel Users

In your case, after loading the data (which we assume is my_data) you could do something like below:


# Setup a demo dataframe
mydata = tibble(`ANN[0].EFFECT` = c("missense_variant", as.character(1:10)))

# Filter on ANN[0].EFFECT column
dplyr::filter(.data = mydata, stringr::str_detect(string = `ANN[0].EFFECT`, pattern = "missense_variant"))


Thank you for your reccomendation, time and help with this!

df1 <- df[ which(df$ANN[0].EFFECT = "missense_variant"),]

1 Like