[R] renaming columns

Marc Feldesman feldesmanm at pdx.edu
Sun Jun 25 04:07:24 CEST 2000

I frequently get data sets with cryptically-named variables.  The datasets 
are more useful to me with informative variable names.  I know that I can 
rename variables using the following command:


If I want to do this inside a function (say something I call RenameCol) 
what is the best way to communicate the new.variable.name back to the 
calling frame (e.g.)

RenameCol<-function(dframe, index, newname)
	#code to make certain there *are* dimnames

The above code works in both SPlus and R if the call looks like:

dframe<-RenameCol(dframe, 3, "a.new.name")

Is there a better way to return the new variable name without having to 
make an explicit assignment at the time of calling RenameCol  (i.e. can the 
explicit assignment be made more efficiently within the function using 
"Assign" or "<<-")?

Be gentle.  Although I've used SPlus and now R for more than a year, I've 
rarely needed to create functions that change specific attributes of an 
object.  (I also do not have VR Programming or VR3 at my disposal right now).


Dr. Marc R. Feldesman
Professor and Chair
Anthropology Department
Portland State University
Portland, Oregon 97207

email: feldesmanm at pdx.edu

Powered by Inspirochoerus

"Indecision may or may not be my problem"

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list