I am trying to rename column names in a dataframe within a function. I am seeing an error (listed below) that I don't understand.
Would be grateful of an explanation of what I am doing wrong and how I should rewrite the function to allow me to be able to rename my variables. Thanks. # Test Function myfunc <-function(var){ d = c(1,2,3,4,5) dts = seq(as.Date("2011-01-01"),by="month",length.out=length(d)) assign(paste(var,".df",sep=""), cbind(dts, d)) names(get(paste(var,".df",sep=""))) <- c("Dates","Data") } # Call Function myfunc("X") # Error Message Error in names(get(paste(var, ".df", sep = ""))) <- c("Dates", "Data") : could not find function "get<-" -- View this message in context: http://r.789695.n4.nabble.com/Renaming-Within-A-Function-tp4226368p4226368.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.