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) {
 tmp<-hist(my.data.frame[,i])
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.

Wade

______________________________________________
R-help@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.

Reply via email to