<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi,<br>
      <br>
      There's no technical reason.  I guess enough people realise now
      that the set* functions change the object by reference. So if
      setnames worked on data.frame :<br>
      <br>
         DF1 = data.frame(a=1:3, b=4:6)<br>
         DF2 = DF1<br>
         setnames(DF2, "b", "B")<br>
      <br>
      This would change both DF1 and DF2.  There might be someone who
      throws up their hands in horror and says this breaks everything
      they've known about data.frame, too. Isn't it enough that
      data.table breaks everything already?<br>
      <br>
      We'd have to take a deep breath and calmly explain copy() is
      needed :<br>
      <br>
         DF1 = data.frame(a=1:3, b=4:6)<br>
         DF2 = copy(DF1)<br>
         setnames(DF2, "b", "B")<br>
      <br>
      So the reason setnames() hasn't so far been enabled for data.frame
      is just for safety (using it on a data.frame accidentally) and to
      avoid complaints and negative Twitterers.   On the other hand
      setnames (different from setNames) is a data.table function so
      it's not like we're overloading <- or anything.<br>
      <br>
      I suppose setnames() could copy the whole DF2 just like base.  But
      that defeats it's purpose, set* functions work by reference.  
      setnames() is a little different in that it's more convenient and
      safer than base syntax, too, though; e.g., changing a column name
      by name.  So I can see someone might want to use it for that
      reason alone and not mind it copies the whole DF when passed a DF.<br>
      <br>
      Matt<br>
      <br>
      <br>
      On 01/10/13 20:51, Ricardo Saporta wrote:<br>
    </div>
    <blockquote
cite="mid:CAE7Aa4QB-eZiM1YTkYE2TN8feZ6dW92v8cP66=k_wuFPVD2fyw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Hi All, </div>
        <div><br>
        </div>
        <div>I'm wondering if there are any potential problems or
          unforseen pitfalls with having</div>
        <div><br>
        </div>
        <div>  setnames(x, nms)</div>
        <div><br>
        </div>
        <div>call</div>
        <div>
             setattr(x, "names", nms)</div>
        <div><br>
        </div>
        <div>when x is not a data.table. </div>
        <div><br>
        </div>
        <div>Thoughts? </div>
        <div><br>
        </div>
        Rick<br clear="all">
        <div>
          <div
            style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
            <div style="font-size:13px"><br>
            </div>
            <div style="font-size:13px">Ricardo Saporta</div>
            <div style="font-size:13px">Graduate Student, Data Analytics</div>
            <div style="font-size:13px"><span style="font-size:13px">Rutgers
                University, New Jersey</span></div>
            <div style="font-size:13px"><span style="font-size:13px">e: </span><a
                moz-do-not-send="true" href="mailto:saporta@rutgers.edu"
                style="color:rgb(17,85,204);font-size:13px"
                target="_blank">saporta@rutgers.edu</a></div>
            <div><br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
datatable-help mailing list
<a class="moz-txt-link-abbreviated" href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></pre>
    </blockquote>
    <br>
  </body>
</html>