title: How to check whether two rows have an equal value pr id for a dataframe in R
body: <p>I have a dataframe, and I would like to check whether there are duplicated values for a specific column for each id. How can I identify duplicated rows, that are not only duplicated on id, but also the 'value' column?</p>
  <pre><code>df &lt;- data.frame('id' = c('1','1', '2', '3', '3', '4','5','5','5'), &quot;value&quot; = c('apple','apple', 'orange', 'banana', 'banana',  'apple','orange','banana','orange'), &quot;shop&quot; = c('supermarket','café', 'café', 'supermarket', 'café',  'supermarket','supermarket','supermarket','café'))
  </code></pre>
  <p>My approach has been</p>
  <pre><code>#extract duplicates in the dataframe on value
  df_dup &lt;- df[duplicated(df$value), ]
  #from this df, extract duplicates on id
  df_dup1 &lt;- df_dup[duplicated(df_dup$id), ]
  </code></pre>
  <p>However this method does not work. The output I am looking for is a reduced dataframe where only id's that have a duplicated value on the 'value'-column are kept together with the other variables in the dataframe:</p>
  <pre><code>df_exp &lt;- data.frame('id' = c('1','1','3', '3', '5','5'), &quot;value&quot; = c('apple','apple', 'banana', 'banana', 'orange','orange'), &quot;shop&quot; = c('supermarket', 'café', 'supermarket', 'café' ,'supermarket','café'))
  </code></pre>
  <p>Thanks in advance!</p>