Re: [R] rewrite script to eliminate constant object reference

2013-06-13 Thread bcrombie
Thanks very much to everyone for their replies, especially Ista, who took the time to write script. Before posting the question I had tried attach() and then within or with statements and now know why those generated errors. Some of my syntax was incorrect. Thanks for clearing that up. "Within"

Re: [R] rewrite script to eliminate constant object reference

2013-06-12 Thread Ista Zahn
Hi, Here are some examples using the mtcars dataset that you can modify to work with your data. ## Here is my first try using within. ## Somehow the elements of region that ## should be zero are converted to NA mtcars <- within(mtcars, { region <- 0 region[gear==4&carb==4] <- 1 regio

Re: [R] rewrite script to eliminate constant object reference

2013-06-12 Thread Jim Holtman
Check out 'with' and 'within'. Sent from my Verizon Wireless 4G LTE Smartphone Original message From: bcrombie Date: 06/12/2013 16:36 (GMT-05:00) To: r-help@r-project.org Subject: [R] rewrite script to eliminate constant object reference I'm adding a column (region) to

Re: [R] rewrite script to eliminate constant object reference

2013-06-12 Thread Greg Snow
If you want an easy way to change the name of the data frame for assignment then you may want a macro. There is an article in the R journal ( http://cran.r-project.org/doc/Rnews/Rnews_2001-3.pdf) on creating macros and there are tools that help with creating macros in the gtools package. Though w