How about
apply(df, 1, function(r) any(r %in% c("M017", "M018")))
The ith element will be TRUE
if the ith row contains one of the values, and FALSE
otherwise. Or, if you want just the row numbers, enclose the above statement in which(...)
.
More Related Contents:
- how to apply a function on a data set?
- Sample random rows in dataframe
- How to change the locale of R?
- Replacing character values with NA in a data frame
- Coerce multiple columns to factors at once
- Delete rows that exist in another data frame? [duplicate]
- How to display only integer values on an axis using ggplot2
- Aggregate multiple columns at once [duplicate]
- How to listen for more than one event expression within a Shiny eventReactive handler
- Place a legend for each facet_wrap grid in ggplot2
- Import text file as single character string
- R tick data : merging date and time into a single object
- Finding the indexes of multiple/overlapping matching substrings
- Controlling line color and line type in ggplot legend
- R Shiny: reactiveValues vs reactive
- Add a “rank” column to a data frame
- Find the intersection of overlapping ranges in two tables using data.table function foverlaps
- Create a matrix of scatterplots (pairs() equivalent) in ggplot2
- How to make graphics with transparent background in R using ggplot2?
- Referring to data.table columns by names saved in variables
- What is integer overflow in R and how can it happen?
- How to extract Month from date in R
- R semicolon delimited a column into rows
- Convert a dataframe to a vector (by rows)
- Get all the rows with rownames starting with ABC111
- How to replace certain values in a specific rows and columns with NA in R?
- Make a file writable in order to add new packages
- Quantmod Error ‘cannot open URL’
- R Warning ‘length(x) = 2 > 1’ in coercion to ‘logical(1)’
- paste two data.table columns