[R] altering prefix to multiple variables in different locations within a command file

Charilaos Skiadas skiadas at hanover.edu
Mon Mar 12 23:40:45 CET 2007


On Mar 12, 2007, at 4:54 PM, Bob Green wrote:

> Hello,
>
> I am seeking advice regarding how I might add the prefix " kc$ " to
> variables in  a series of commands. The complication is that there is
> a large number of variables with different commands. Examples of the
> variables in typical commands follow.

Maybe I've misunderstood what you want to do, but would "with" meet  
the case?

 > a
Error: object "a" not found
 > x<-list(a=5)
 > with(x,a)
[1] 5
 > x$a
[1] 5
 >

See ?with


> It is simple to use search & replace for common variables such as
> "group" but I would appreciate advice about whether there is a  way
> to readily alter the remaining variables.
>
> Bob Green

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College



More information about the R-help mailing list