title: How to create a function where the user picks rows of a data frame based on a character vector
body: <p>I need to create a function (using the function() code) that will let a user enter their name as a character in a vector called <code>myname</code>. The function will create a data frame that is a subset of <code>babynames</code>, including only rows where <code>name</code> is in <code>myname</code>.</p>
  
  <p>I tried writing the code, but the part I can't seem to understand is: how does the function know that <code>myname</code> will be found in the <code>names</code> column of the data frame? I also thought I made the subset correctly but when I run it, it has 0 observations. </p>
  
  <p>Here is some sample data</p>
  
  <p><img src="https://i.stack.imgur.com/9j2YJ.png" alt="I don&#39;t know how to add sample data so here&#39;s a picture of the top of the table"></p>
  
  <pre><code>nametrend &lt;- function(myname) {
      bn &lt;- subset(babynames, name == myname, select = c("year", "n")) plot(x = bn$year, y = bn$n, main = myname, col = 'purple')
  }
  </code></pre>