First, split the df$ID
by Month
and use intersect
to find elements common in each sub-group.
Reduce(intersect, split(df$ID, df$Month))
#[1] 4 6
If you want to subset the corresponding data.frame, do
df[df$ID %in% Reduce(intersect, split(df$ID, df$Month)),]
More Related Contents:
- How to find common elements from multiple vectors?
- Generate multiple graphics from within an R function
- Frequency counts in R [duplicate]
- Explain a lazy evaluation quirk
- Tools for making latex tables in R [closed]
- Efficient way to rbind data.frames with different columns
- Change bar plot colour in geom_bar with ggplot2 in r
- Lattice: multiple plots in one window?
- What are the differences between “=” and “
- Escaping backslash (\) in string or paths in R
- define $ right parameter with a variable in R [duplicate]
- R: data.table cross-join not working
- How to randomize (or permute) a dataframe rowwise and columnwise?
- in R, use gsub to remove all punctuation except period
- Create zip file: error running command ” ” had status 127
- Subsetting a data frame based on contents of another data frame
- Identify all objects of given class for further processing
- Importing two functions with same name using roxygen2
- How to get top n companies from a data frame in decreasing order
- Any suggestions for how I can plot mixEM type data using ggplot2
- MATCH function in r [duplicate]
- Converting factors to binary in R
- Return df with a columns values that occur more than once [duplicate]
- How to find the indices of the top 10,000 elements in a symmetric matrix(12k X 12k) in R
- Generate ggplot2 boxplot with different colours for multiple groups
- Convert a data frame to a data.table without copy
- How to add shaded confidence intervals to line plot with specified values
- How to calculate adjacency matrices in R
- Removing Unused Factors from a Facet in ggplot2
- What is the first column in R’s mtcars dataset?