[R] Rename objects based on list

From: Wade Wall <wade.wall_at_gmail.com>
Date: Sat, 15 Nov 2008 13:33:56 -0500

Hi all,

I am trying to find a way to rename R objects with names pulled from a vector of names. For example, I have a data frame, my.data.frame, and a list of names, my.names. My.names is simply the column names of my.data.frame.

I want save the histogram with the column name as the name of the object.

for (i in 1:ncol(my.data.frame) {
name(tmp)<-my.names[i] ##This is not real code, but what I want to do, which is change the name of tmp to the name held at my.names[,i] }

Basically, I am looking for a way to loop through columns in a data frame, perform some function on the column, and name the output based on the name of the column.

Thanks for any help.


R-help_at_r-project.org 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. Received on Sat 15 Nov 2008 - 18:37:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 15 Nov 2008 - 19:31:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive