Here is a solution using dplyr >= 0.5
.
library(dplyr)
set.seed(123)
df <- data.frame(
x = sample(0:1, 10, replace = T),
y = sample(0:1, 10, replace = T),
z = 1:10
)
> df %>% distinct(x, y, .keep_all = TRUE)
x y z
1 0 1 1
2 1 0 2
3 1 1 4
More Related Contents:
- Gather multiple sets of columns
- How to get summary statistics by group
- Is there a dplyr equivalent to data.table::rleid?
- Replace NA with previous or next value, by group, using dplyr
- Filter rows which contain a certain string
- Calculate group mean, sum, or other summary stats. and assign column to original data
- Concatenate strings by group with dplyr [duplicate]
- What does %>% function mean in R?
- Display / print all rows of a tibble (tbl_df)
- R cumulative sum by condition with reset
- How to strsplit different number of strings in certain column by do function
- Finding Overlaps between interval sets / Efficient Overlap Joins
- R dplyr rolling sum
- How to remove rows with any zero value
- Select columns based on string match – dplyr::select
- Delete columns/rows with more than x% missing
- How to aggregate a dataframe by week?
- Mutate multiple columns in a dataframe
- adding default values to item x group pairs that don’t have a value (df %>% spread %>% gather seems strange)
- mutate_each / summarise_each in dplyr: how do I select certain columns and give new names to mutated columns?
- dplyr mutate rowwise max of range of columns
- dplyr: lead() and lag() wrong when used with group_by()
- Reorder rows using custom order
- Cartesian product with dplyr
- Spreading a two column data frame with tidyr
- Categorize continuous variable with dplyr [duplicate]
- R dplyr rowwise mean or min and other methods?
- dplyr: put count occurrences into new variable [duplicate]
- Add row in each group using dplyr and add_row()
- How to replace certain values in a specific rows and columns with NA in R?