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
  • 80,151
  • 7
  • 17
  • 65
arto
  • 41
  • 3

2 Answers2

1

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

library(tidyverse)

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

A base R option using subset + rowSums

subset(df,rowSums(df=="yellow")>0)
ThomasIsCoding
  • 80,151
  • 7
  • 17
  • 65