We can use replace
to change the values in ‘mpg’ to NA
that corresponds to cyl==4
.
mtcars %>%
mutate(mpg=replace(mpg, cyl==4, NA)) %>%
as.data.frame()
More Related Contents:
- Reshape three column data frame to matrix (“long” to “wide” format) [duplicate]
- Why does summarize or mutate not work with group_by when I load `plyr` after `dplyr`?
- How to select the rows with maximum values in each group with dplyr? [duplicate]
- Convert data from long format to wide format with multiple measure columns
- Fastest way to add rows for missing time steps?
- Unique rows, considering two columns, in R, without order
- R spreading multiple columns with tidyr [duplicate]
- Applying a function to every row of a table using dplyr?
- dplyr summarise: Equivalent of “.drop=FALSE” to keep groups with zero length in output
- dplyr: nonstandard column names (white space, punctuation, starts with numbers)
- dplyr: “Error in n(): function should not be called directly”
- Count number of rows by group using dplyr
- dplyr filter with condition on multiple columns
- How to strsplit different number of strings in certain column by do function
- How to add a cumulative column to an R dataframe using dplyr?
- Get last row of each group in R [duplicate]
- R – add column that counts sequentially within groups but repeats for duplicates
- dplyr – filter by group size
- Why is plyr so slow?
- Merge rows in a dataframe where the rows are disjoint and contain NAs
- Split Data Frame into Rows of Fixed Size
- R: Split unbalanced list in data.frame column
- mutate_each / summarise_each in dplyr: how do I select certain columns and give new names to mutated columns?
- finding close match from data frame 1 in data fame 2
- dplyr change many data types
- Join two data frames in R based on closest timestamp
- How to dplyr rename a column, by column index?
- How to add only missing Dates in Dataframe
- Override column types when importing data using readr::read_csv() when there are many columns
- Adding column if it does not exist