Re: [R] Confusing behaviour in data.table: unexpectedly changing variable

2013-09-25 Thread Jonathan Dushoff
Thanks for your help, and sorry for mis-posting. JD On Wed, Sep 25, 2013 at 3:18 AM, Matthew Dowle wrote: > Very sorry to hear this bit you. If you need a copy of names before > changing them by reference : > oldnames <- copy(names(DT)) > This will be documented and it's on the bug list

Re: [R] Confusing behaviour in data.table: unexpectedly changing variable

2013-09-25 Thread Matthew Dowle
Very sorry to hear this bit you. If you need a copy of names before changing them by reference : oldnames <- copy(names(DT)) This will be documented and it's on the bug list to do so. copy is needed in other circumstances too, see ?copy. More details here : http://stackoverflow.com/q

[R] Confusing behaviour in data.table: unexpectedly changing variable

2013-09-24 Thread Jonathan Dushoff
I got bitten badly when a variable I created for the purpose of recording an old set of names changed when I didn't think I was going near it. I'm not sure if this is a desired behaviour, or documented, or warned about. I read the data.table intro and the FAQ, and also ?setnames. Ben Bolker crea