title: Plotting a subset of a dataframe with R?
body: <p>I have a data frame called <code>fin</code>:</p>
  
  <pre><code>str(fin)
  'data.frame':   158 obs. of  9 variables:
   $ Species      : chr  "TRAT" "TRAT" "TRAT" "WRAT" ...
   $ Site         : chr  "BAN" "BEX" "BEX" "BEX" ...
   $ Year         : chr  "2011" "2010" "2011" "2012" ...
   $ FR.CoYear: num  35.7 123.6 136.4 215.8 145.2 ...
   $ Sample       : int  31 NA 929 809 NA NA NA 30 215 NA ...
   $ Young        : num  16 NA 828 709 NA NA NA 45 235 NA ...
   $ SiteYear     : Factor w/ 65 levels "BAN 2011","BAN 2012",..: 1 4 5 6 7 1
  </code></pre>
  
  <p>I would like to plot <code>FR.CoYear</code> against <code>(fin$Young / fin$Sample)</code> separately for each of the 5 species in <code>$Species</code>.</p>
  
  <p>I tried the ways suggested <a href="https://stackoverflow.com/questions/8293547/how-to-plot-a-subset-of-a-data-frame-in-r">here</a>; but none are currently working, I would be very grateful for guidance - is this just a syntax problem?</p>
  
  <p>This is what I have tried:</p>
  
  <pre><code>with(subset(fin,fin$Species == "TRAT"), plot(fin$FR.CoYear, fin$Young /fin$Sample))
   ## runs without error but no plot is produced
  
  with(fin[fin$Species == "TRAT",], plot((fin$FR.CoYear, fin$Young / fin$Sample))
  ##gives the error: unexpected ',' in "with(fin[fin$Species == "TRAT",], plot((fin$FR.CoYear,"
  
  plot(fin$FR.CoYear[fin$Species == "BLKI"],fin$Young / fin$Sample[fin$Species == "BLKI"])
  ##Error in xy.coords(x, y, xlabel, ylabel, log) : 
    'x' and 'y' lengths differ 
  </code></pre>
  
  <p>I apologise if this is very basic, but am teaching myself R.</p>