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

Stephen Tucker brown_emu at yahoo.com
Tue Mar 13 00:03:20 CET 2007


I think what you are looking for is attach()?

attach(kc)
# commands (don't need to prefix variables with "kc$")
detach(kc)

In this way an environment is created in which you can refer to the variables
in your data frame without the "kc$" prefix.
(see ?attach)


--- Bob Green <bgreen at dyson.brisnet.org.au> 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.
> 
> 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
> 
> 
> CrossTable(group,TOC2,chisq=TRUE,resid=TRUE, missing.include=FALSE)
> fisher.test(group,TOC2)
> 
> tapply(TOC2,  group,  mean)
> tapply( TOC2,  group, sd)
> 
> oneway.test ( TOC2 ~  group, var.equal=FALSE)
> kruskal.test ( TOC2 ~  group)
> 
> 
> broadcast  ==""
> broadcast   [broadcast  ==""] <- "n"
> CrossTable( group,broadcast   ,chisq=TRUE,resid=TRUE,
> missing.include=FALSE)
> fisher.test(group,broadcast)
> 
> jealous [jealous=="y (not victim)"] = "n"
> jealous==""
> jealous [jealous==""] <- "n"
> jealous==""
> CrossTable(group,jealous ,chisq=TRUE,resid=TRUE, missing.include=FALSE)
> fisher.test(group,jealous)
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



 
____________________________________________________________________________________
No need to miss a message. Get email on-the-go



More information about the R-help mailing list