search for: colrenam

Displaying 2 results from an estimated 2 matches for "colrenam".

Did you mean: colrename
2010 Oct 13
4
Change global env variables from within a function
...to the data frame in the global environment in a simple manner. Given: tempdf <- data.frame("a" = 1:6, "b" = 7:12) #I can rename a to g this way: names(tempdf)[names(tempdf)=="a"] <- "g" #Wanting to simplify this for the future, I have the function: colrename <- function(dframe, oldname, newname) { names(dframe)[names(dframe)==oldname] <- newname } colrename(tempdf, "a", "g") #However of course the change to tempdf stays within colrename(). I could add "return(names(dframe))" to the function and then ca...
2010 Oct 15
0
nomianl response model
...to the data frame in the global environment in a simple manner. Given: tempdf <- data.frame("a" = 1:6, "b" = 7:12) #I can rename a to g this way: names(tempdf)[names(tempdf)=="a"] <- "g" #Wanting to simplify this for the future, I have the function: colrename <- function(dframe, oldname, newname) { names(dframe)[names(dframe)==oldname] <- newname } colrename(tempdf, "a", "g") #However of course the change to tempdf stays within colrename(). I could add "return(names(dframe))" to the function and then ca...