title: How can I create a column identifying rows consisting only of new data in a summarized data frame?
body: <p>I have a dataset that is built off of a prior study but includes a number of entirely new entries. The dataset, when cleaned, consists of the mean value for each of the species included in the study which I have been creating using the <code>summarise</code> function in <code>tidyverse</code>.</p>
  <pre><code>df&lt;-data.frame(species = c(&quot;Species1&quot;,&quot;Species1&quot;,&quot;Species2&quot;,&quot;Species2&quot;,&quot;Species3&quot;,&quot;Species3&quot;),
                 new=c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE),var=c(1,1,2,2,3,3))
  df2&lt;-df%&gt;%
    group_by(species)%&gt;%
    summarise(var=mean(var))
  </code></pre>
  <p>I have a column listing whether the observations are new to the study or are drawn from the parent study. What I am trying to do is create a vector in the cleaned data frame so that I can easily show and summarize how many new species have been added by this study. There are some observations which are additional data for already present species, but other species are entirely novel to the present analysis. I am trying to figure out a way to create a vector column to list if a <em><strong>only</strong></em> if this species is entirely new to this study, such that it produces a data frame/tibble like the following.</p>
  <pre><code>data.frame(species=c(&quot;Species1&quot;,&quot;Species2&quot;,&quot;Species3&quot;),new=c(&quot;TRUE&quot;,&quot;FALSE&quot;,&quot;FALSE&quot;),var=c(1,2,3))
  </code></pre>
  <p>In this data frame, Species 1 is entirely new, Species 2 has both old and new observations, and Species 3 has entirely old observations. Thus only Species 1 is true for the &quot;new&quot; vector I am trying to create.</p>
  <p>I know how to mutate columns based on and/or statements using &quot;&amp;&quot; and &quot;|&quot; for certain levels in another column, but I'm not sure how to create a column where new = TRUE if none of the respective entries used to create the summarized value have a certain level or character string. I think it might be possible using an <code>ifelse()</code> statement but I'm not sure how to write the code to it considers each level of <code>species</code>.</p>