The R Project SVN R

Rev

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

Rev 27625 Rev 27712
Line 77... Line 77...
77
  \emph{Group} methods for \code{data.frame}s;
77
  \emph{Group} methods for \code{data.frame}s;
78
  \code{\link{read.table}},
78
  \code{\link{read.table}},
79
  \code{\link{make.names}}.
79
  \code{\link{make.names}}.
80
}
80
}
81
\examples{
81
\examples{
82
require(utils)
-
 
83
L3 <- LETTERS[1:3]
82
L3 <- LETTERS[1:3]
84
str(d <- data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, repl=TRUE)))
83
(d <- data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, repl=TRUE)))
85
 
84
 
86
## The same with automatic column names:
85
## The same with automatic column names:
87
str(     data.frame(cbind(  1,   1:10),     sample(L3, 10, repl=TRUE)))
86
data.frame(cbind(  1,   1:10),     sample(L3, 10, repl=TRUE))
-
 
87
 
88
is.data.frame(d)
88
is.data.frame(d)
89
 
89
 
90
## do not convert to factor, using I() :
90
## do not convert to factor, using I() :
91
str(cbind(d, char = I(letters[1:10])), vec.len = 10)
91
(dd <- cbind(d, char = I(letters[1:10])))
-
 
92
rbind(class=sapply(dd, class), mode=sapply(dd, mode))
92
 
93
 
93
stopifnot(1:10 == row.names(d))# {coercion}
94
stopifnot(1:10 == row.names(d))# {coercion}
94
 
95
 
95
(d0  <- d[, FALSE]) # NULL data frame with 10 rows
96
(d0  <- d[, FALSE]) # NULL data frame with 10 rows
96
(d.0 <- d[FALSE, ]) # <0 rows> data frame  (3 cols)
97
(d.0 <- d[FALSE, ]) # <0 rows> data frame  (3 cols)