1

I have a dataframe, that contains e.g. 5 rows and 3 columns:

dataframe

I would like to select those rows, which contains for example text yellow (rows 1 and 4)?

ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
arto
  • 61
  • 4

2 Answers2

2

Use the following to select rows that contain "yellow" in any column:

library(tidyverse)

result <- mydata %>%
  filter_all(any_vars(. == "yellow"))
Rory S
  • 1,278
  • 5
  • 17
0

A base R option using subset + rowSums

subset(df,rowSums(df=="yellow")>0)
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81