<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"><br>
      Rick,<br>
      <br>
      Oh - setnames already does work on data.frame.   That was a change
      in v1.8.4.<br>
      <br>
      Was the question more for lists and vectors then (anything that
      can have names),  rather than just data.frame/data.table?<br>
      <br>
      Matt<br>
      <br>
      On 02/10/13 15:13, Matt Dowle wrote:<br>
    </div>
    <blockquote cite="mid:524C29F5.5030207@mdowle.plus.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 02/10/13 12:50, Ricky Saporta
        wrote:<br>
      </div>
      <blockquote
        cite="mid:085806D7-2265-4EDE-B47E-5822BD73E3BB@scarletmail.rutgers.edu"
        type="cite">
        <meta http-equiv="content-type" content="text/html;
          charset=ISO-8859-1">
        <div><br>
        </div>
        <div>
          <div style="-webkit-tap-highlight-color: rgba(26, 26, 26,
            0.296875); -webkit-composition-fill-color: rgba(175, 192,
            227, 0.230469); -webkit-composition-frame-color: rgba(77,
            128, 180, 0.230469); ">This might be a topic to raise in a
            separate email: </div>
          <div style="-webkit-tap-highlight-color: rgba(26, 26, 26,
            0.296875); -webkit-composition-fill-color: rgba(175, 192,
            227, 0.230469); -webkit-composition-frame-color: rgba(77,
            128, 180, 0.230469); ">What do you think of adapting a
            naming convention where the name of the function indicates
            when a function will modify an object by reference?  In my
            personal work, I have been trying to end such functions with
            an underscore.  Putting aside for the moment all obvious and
            not so obvious issues with changing the names of existing
            functions & backwards compatibility, is the idea itself
            worth considering? <br>
          </div>
        </div>
      </blockquote>
      <br>
      Maybe.  But the convention was already that any function started
      "set" indicates it will change the object by reference. The
      documentation uses "set*" in several places with this in mind.<br>
      <br>
      > objects("package:data.table", pattern="^set")<br>
      [1] "set"         "setattr"     "setcolorder" "setkey"     
      "setkeyv"    <br>
      [6] "setnames"   <br>
      > <br>
      <br>
      If the functions insert() and delete() are added, they'll add and
      remove rows by reference.  Those verbs don't start with set, but
      it's clear (in my mind) that they'd change the data.table by
      reference; e.g. insert(DT, row number | "end", some data).<br>
      <br>
      Looking at base etc for functions starting "set*" there's some
      side-effect meaning intended there too (setwd, setTimeLimit,
      set.seed).  setdiff and setequal are about sets in the collection
      sense.  So it's just setNames as a one off really.   And we don't
      use camelCase in data.table, so that's how to remember that.<br>
      <br>
      > objects("package:base", pattern="^set")<br>
      [1] "setdiff"             "setequal"           
      "setHook"            <br>
      [4] "setNamespaceInfo"    "set.seed"           
      "setSessionTimeLimit"<br>
      [7] "setTimeLimit"        "setwd"              <br>
      > objects("package:stats", pattern="^set")<br>
      [1] "setNames"<br>
      > objects("package:utils", pattern="^set")<br>
      [1] "setBreakpoint"     "setRepositories"   "setTxtProgressBar"<br>
      <br>
      Since other set* functions work on data.frame  (set() for
      example!), setnames should too.  I was forgetting that. Let's
      change it then.<br>
      <br>
      Matt<br>
      <br>
      <blockquote
        cite="mid:085806D7-2265-4EDE-B47E-5822BD73E3BB@scarletmail.rutgers.edu"
        type="cite">
        <div style="-webkit-tap-highlight-color: rgba(26, 26, 26,
          0.296875); -webkit-composition-fill-color: rgba(175, 192, 227,
          0.230469); -webkit-composition-frame-color: rgba(77, 128, 180,
          0.230469); "><br>
        </div>
        <div style="-webkit-tap-highlight-color: rgba(26, 26, 26,
          0.296875); -webkit-composition-fill-color: rgba(175, 192, 227,
          0.230469); -webkit-composition-frame-color: rgba(77, 128, 180,
          0.230469); ">Rick </div>
        <div><br>
        </div>
        <br>
        <blockquote type="cite">
          <div>
            <div class="moz-cite-prefix"> <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 moz-do-not-send="true" 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 moz-do-not-send="true" 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>
          </div>
        </blockquote>
      </blockquote>
      <br>
      <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>