<div>DT = data.table(A=letters[1:5],B=rnorm(5),C=rexp(5),D=runif(5))</div><div>DT2=DT[,c(1,4,2),with=FALSE]<br></div><div># If you really want the name changes</div><div>setnames(DT2, c('a','d','B'))</div>
<div><br></div><div>On Mon Jul 21 2014 at 7:01:26 AM, Frank S. <<a href="mailto:f_j_rod@hotmail.com">f_j_rod@hotmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div dir="ltr">Hi everyone,<br> <br>For instance, let's suppose I have the an initial data frame DF, and I want to<br>rename and reorder some of its columns, so that the desired result is<br>expressed by DF2:<br>
 <br> <br>set.seed(100)<br>DF = data.frame(A=letters[1:5],B=rnorm(5),C=rexp(5),D=runif(5))<br>DF2 <- data.frame(a=DF[,1],d=DF[,4],B=DF[,2])<br><br>If I do the equivalent operations under data table format, I'm onñy able to obtain<br>
the same result with the following code:<br> <br> <br>set.seed(100)<br>DT = data.table(A=letters[1:5],B=rnorm(5),C=rexp(5),D=runif(5))<br>DT2 <- data.table(a=DT[,1,with=FALSE],d=DT[,4,with=FALSE],B=DT[,2,with=FALSE])<br>
 <br> <br>Please, is it possible to get the same result with a more simply code?<br>Thanks!<br>                                         </div></div>
______________________________<u></u>_________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.<u></u>r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-<u></u>project.org/cgi-bin/mailman/<u></u>listinfo/datatable-help</a></blockquote>