The R Project SVN R

Rev

Rev 70587 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70587 Rev 70594
Line 18... Line 18...
18
  corresponding to such a division.  \code{unsplit} reverses the effect of
18
  corresponding to such a division.  \code{unsplit} reverses the effect of
19
  \code{split}.
19
  \code{split}.
20
}
20
}
21
\usage{
21
\usage{
22
split(x, f, drop = FALSE, \dots)
22
split(x, f, drop = FALSE, \dots)
23
\method{split}{default}(x, f, drop = FALSE, lex.order = FALSE, \dots)
23
\method{split}{default}(x, f, drop = FALSE, sep = ".", lex.order = FALSE, \dots)
24
 
24
 
25
split(x, f, drop = FALSE, \dots) <- value
25
split(x, f, drop = FALSE, \dots) <- value
26
unsplit(value, f, drop = FALSE)
26
unsplit(value, f, drop = FALSE)
27
}
27
}
28
\arguments{
28
\arguments{
Line 32... Line 32...
32
    interaction is used for the grouping.}
32
    interaction is used for the grouping.}
33
  \item{drop}{logical indicating if levels that do not occur should be dropped
33
  \item{drop}{logical indicating if levels that do not occur should be dropped
34
    (if \code{f} is a \code{factor} or a list).}
34
    (if \code{f} is a \code{factor} or a list).}
35
  \item{value}{a list of vectors or data frames compatible with a
35
  \item{value}{a list of vectors or data frames compatible with a
36
    splitting of \code{x}. Recycling applies if the lengths do not match.}
36
    splitting of \code{x}. Recycling applies if the lengths do not match.}
37
  \item{lex.order}{logical, passed to \code{\link{interaction}} in the
37
  \item{sep}{character string, passed to \code{\link{interaction}} in the
38
    case where \code{f} is a \code{\link{list}}.}
38
    case where \code{f} is a \code{\link{list}}.}
-
 
39
  \item{lex.order}{logical, passed to \code{\link{interaction}} when
-
 
40
    \code{f} is a list.}
39
  \item{\dots}{further potential arguments passed to methods.}
41
  \item{\dots}{further potential arguments passed to methods.}
40
}
42
}
41
\details{
43
\details{
42
  \code{split} and \code{split<-} are generic functions with default and
44
  \code{split} and \code{split<-} are generic functions with default and
43
  \code{data.frame} methods.  The data frame method can also be used to
45
  \code{data.frame} methods.  The data frame method can also be used to
44
  split a matrix into a list of matrices, and the replacement form
46
  split a matrix into a list of matrices, and the replacement form
45
  likewise, provided they are invoked explicitly.
47
  likewise, provided they are invoked explicitly.
46
 
48
 
47
  \code{unsplit} works with lists of vectors or data frames (assumed to
49
  \code{unsplit} works with lists of vectors or data frames (assumed to
48
  have compatible structure, as if created by \code{split}). It puts
50
  have compatible structure, as if created by \code{split}).  It puts
49
  elements or rows back in the positions given by \code{f}. In the data
51
  elements or rows back in the positions given by \code{f}.  In the data
50
  frame case, row names are obtained by unsplitting the row name
52
  frame case, row names are obtained by unsplitting the row name
51
  vectors from the elements of \code{value}.
53
  vectors from the elements of \code{value}.
52
 
54
 
53
  \code{f} is recycled as necessary and if the length of \code{x} is not
55
  \code{f} is recycled as necessary and if the length of \code{x} is not
54
  a multiple of the length of \code{f} a warning is printed.
56
  a multiple of the length of \code{f} a warning is printed.
55
 
57
 
56
  Any missing values in \code{f} are dropped together with the
58
  Any missing values in \code{f} are dropped together with the
57
  corresponding values of \code{x}.
59
  corresponding values of \code{x}.
58
 
60
 
59
  The default method calls \code{\link{interaction}}.  If the levels of
61
  The default method calls \code{\link{interaction}} when \code{f} is a
-
 
62
  \code{\link{list}}.  If the levels of the factors contain \samp{.}
60
  the factors contain \samp{.} they may not be split as expected, so
63
  the factors may not be split as expected, unless \code{sep} is set to
61
  the method has argument \code{sep} which is use to join the levels.
64
  string not present in the factor \code{\link{levels}}.
62
}
65
}
63
\value{
66
\value{
64
  The value returned from \code{split} is a list of vectors containing
67
  The value returned from \code{split} is a list of vectors containing
65
  the values for the groups.  The components of the list are named by
68
  the values for the groups.  The components of the list are named by
66
  the levels of \code{f} (after converting to a factor, or if already a
69
  the levels of \code{f} (after converting to a factor, or if already a