[R] Rename Variable and package gdata

Duncan Murdoch murdoch at stats.uwo.ca
Sat Nov 17 22:51:20 CET 2007


On 17/11/2007 3:45 PM, Elerslie at aol.com wrote:
> Dear R-helpers,
>  
> I hope someone can help me with the following problem:
>  
> I derived a variable from many others and produced data.frame:  toktempo
> When I look at the variable name I get:
>  
> names(toktempo)
> [1] "otok.V5"
> 
> But I want the variable name to be Tempo so I googled around to find info 
> about renaming variables.

You can simply say

names(toktempo) <- "Tempo"

However, a few more comments about your troubles below...

> I found a webpage which seemed to indicate to me that there was a package 
> named gmisc which contained a function called rename and it's syntax looked like 
> what I wanted.  Another webpage indicated that gmisc is a bundle and there are 
> four packages: gtools, gdata, gmodels, and gplots.  I think gdata might have 
> the rename function.  So I did:
>  
> chooseCRANmirror()
> install.packages(c("gdata"))
> 
> After this, library() shows that I now have gdata:
>  
> Packages in library 'C:/PROGRA~1/R/R-23~1.0/library':

You didn't say what version of R you're using, but that looks like 
2.3.0:  an old one.  I'd update to 2.6.0 (or wait a couple of weeks and 
update to 2.6.1).  In that version, install.packages("gdata") would have 
installed the necessary dependencies.  I think you can get similar 
behaviour in your version by

install.packages("gdata", dependencies=TRUE)

However, the current version of gdata requires R 2.4.0 or better, so 
you'll be installing an obsolete version of the package, too.

Duncan Murdoch

>  
> base                    The R Base Package
> boot                    Bootstrap R (S-Plus) Functions (Canty)
> class                   Functions for Classification
> cluster                 Cluster Analysis Extended Rousseeuw et al.
> datasets                The R Datasets Package
> foreign                 Read Data Stored by Minitab, S, SAS, SPSS,
> Stata, Systat, dBase, ...
> gdata                   Various R programming tools for data
> manipulation
> graphics                The R Graphics Package
> grDevices               The R Graphics Devices and Support for Colours
> and Fonts
> grid                    The Grid Graphics Package
> KernSmooth              Functions for kernel smoothing for Wand & Jones
> (1995)
> lattice                 Lattice Graphics
> MASS                    Main Package of Venables and Ripley's MASS
> methods                 Formal Methods and Classes
> mgcv                    GAMs with GCV smoothness estimation and GAMMs
> by REML/PQL
> nlme                    Linear and nonlinear mixed effects models
> nnet                    Feed-forward Neural Networks and Multinomial
> Log-Linear Models
> 
> But when I do library(gdata) I get:
> 
> Error in loadNamespace(i[[1]], c(lib.loc, .libPaths())) : 
> there is no package called 'gtools'
> In addition: Warning message:
> package 'gdata' was built under R version 2.3.1 
> Error: package/namespace load failed for 'gdata'
> 
> And when I do help(rename) I get:
>  help(rename)
> No documentation for 'rename' in specified packages and libraries:
> you could try 'help.search("rename")'
> 
> Of course I don't really know if gdata includes something called rename but 
> I'm most hoping the message from library(gdata) will mean something to someone. 
>  Or maybe someone has other ideas to help me with my renaming problem.
>  
> Many thanks,
> Tom Brotz
> 
> 
> 
> ************************************** See what's new at http://www.aol.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list