<div dir="ltr">yes, it was mostly in general.  eg <div><br></div><div><div>  X <- 1:5 </div><div>  setnames(X, LETTERS[X])</div></div><div><div>  # Error in setnames(X, LETTERS[X]) : x is not a data.table or data.frame</div>
</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><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 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>
<br><br><div class="gmail_quote">On Wed, Oct 2, 2013 at 12:28 PM, Matt Dowle <span dir="ltr"><<a href="mailto:mdowle@mdowle.plus.com" target="_blank">mdowle@mdowle.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div><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?<span class="HOEnZb"><font color="#888888"><br>
      <br>
      Matt</font></span><div><div class="h5"><br>
      <br>
      On 02/10/13 15:13, Matt Dowle wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      
      <div>On 02/10/13 12:50, Ricky Saporta
        wrote:<br>
      </div>
      <blockquote type="cite">
        
        <div><br>
        </div>
        <div>
          <div>This might be a topic to raise in a
            separate email: </div>
          <div>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 type="cite">
        <div><br>
        </div>
        <div>Rick </div>
        <div><br>
        </div>
        <br>
        <blockquote type="cite">
          <div>
            <div> <br>
              Matt<br>
              <br>
              <br>
              On 01/10/13 20:51, Ricardo Saporta wrote:<br>
            </div>
            <blockquote 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 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></fieldset>
              <br>
              <pre>_______________________________________________
datatable-help mailing list
<a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.r-project.org</a>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></pre>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </blockquote>
      <br>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
datatable-help mailing list
<a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.r-project.org</a>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></pre>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div>