[R-gregmisc-users] SF.net SVN: r-gregmisc: [987] trunk/gdata
Brought to you by:
warnes
From: <wa...@us...> - 2006-10-27 21:15:40
|
Revision: 987 http://svn.sourceforge.net/r-gregmisc/?rev=987&view=rev Author: warnes Date: 2006-10-27 14:15:22 -0700 (Fri, 27 Oct 2006) Log Message: ----------- Add c() method for factor objects, submitted by Gregor Gorjanc Added Paths: ----------- trunk/gdata/R/c.factor.R trunk/gdata/man/c.factor.Rd Added: trunk/gdata/R/c.factor.R =================================================================== --- trunk/gdata/R/c.factor.R (rev 0) +++ trunk/gdata/R/c.factor.R 2006-10-27 21:15:22 UTC (rev 987) @@ -0,0 +1,18 @@ +# $Id$ + +c.factor <- function(..., + recursive=FALSE # ignored + ) +{ + dots <- list(...) # recursive below is not related to one above! + mapCha <- c(mapLevels(dots, codes=FALSE), recursive=TRUE) + class(mapCha) <- "levelsMap" + dots <- unlist(lapply(dots, "mapLevels<-", mapCha)) + mapLevels(dots) <- mapLevels(as.character(mapCha)) + dots +} + + + + + Added: trunk/gdata/man/c.factor.Rd =================================================================== --- trunk/gdata/man/c.factor.Rd (rev 0) +++ trunk/gdata/man/c.factor.Rd 2006-10-27 21:15:22 UTC (rev 987) @@ -0,0 +1,35 @@ +%% $Id$ + +\name{c.factor} +\alias{c.factor} +\title{Combine factors, properly handling levels} +\description{ + This method for \code{c} combines factors while properly preserves level + information. +} +\usage{ +c.factor(..., recursive = FALSE) +} +\arguments{ + \item{\dots}{ factors to be combined } + \item{recursive}{ ignored } +} +\details{ + +} +\value{ + A single factor object. The levels on the new object are created by + concatinating the levels of the provided factors, with any duplicate + level names merged, and with the factor coding modified appropriately. +} +\author{Gregor Gorjan} +\seealso{ \code{\link[base]{c}} } +\examples{ +f1 <- factor(letters[1:10]) +f2 <- factor(letters[5:14]) + +c(f1,f2) + +} +\keyword{manip} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |