File: rename.vars.Rd

package info (click to toggle)
gregmisc 2.0.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,712 kB
  • ctags: 379
  • sloc: perl: 5,142; asm: 127; sh: 30; makefile: 17
file content (59 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% $Id: rename.vars.Rd,v 1.7 2004/04/01 20:23:15 warnes Exp $
%
% $Log: rename.vars.Rd,v $
% Revision 1.7  2004/04/01 20:23:15  warnes
% Add function remove.vars().
%
% Revision 1.6  2002/09/23 13:59:30  warnes
% - Modified all files to include CVS Id and Log tags.
%
%

\name{rename.vars}
\alias{rename.vars}
\alias{remove.vars}
\title{Remove or rename variables in a dataframe }
\description{
  Remove or rename a variables in a data frame.
}
\usage{
rename.vars(data, from="", to="", info=TRUE)
remove.vars(data, names="", info=TRUE)
}
\arguments{
  \item{data}{ dataframe to be modified.  }
  \item{from}{ character vector containing the current name of each
    variable to be renamed.}
  \item{to}{ character vector containing the new name of each variable
    to be renamed.}
  \item{names}{ character vector containing the names of variables to be
    removed.}
  \item{info}{ boolean value indicating whether to print details of the
    removal/renaming.  Defaults to TRUE.}
}
%\details{
%  ~~ If necessary, more details than the __description__  above ~~
%}
\value{
  The updated data frame with variables listed in \code{from} renamed to
  the corresponding element of \code{to}.
}
\author{Code by Don MacQueen \email{macq\@llnl.gov}.
  Documentation by Gregory R. Warnes
  \email{gregory\_r\_warnes\@groton.pfizer.com} }
\seealso{ \code{\link{names}},
  \code{\link{colnames}},
  \code{\link{data.frame}}
}

\examples{
data <- data.frame(x=1:10,y=1:10,z=1:10)
names(data)
data <- rename.vars(data, c("x","y","z"), c("first","second","third"))
names(data)

data <- remove.vars(data, "second")
names(data)
}
\keyword{ manip  }