The R Project SVN R

Rev

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

Rev 74388 Rev 77029
Line 11... Line 11...
11
\alias{row.names<-}
11
\alias{row.names<-}
12
\alias{row.names<-.data.frame}
12
\alias{row.names<-.data.frame}
13
\alias{row.names<-.default}
13
\alias{row.names<-.default}
14
\alias{.rowNamesDF<-}
14
\alias{.rowNamesDF<-}
15
\description{
15
\description{
16
  All data frames have a row names attribute, a character vector of
16
  All data frames have row names, a character vector of
17
  length the number of rows with no duplicates nor missing values.
17
  length the number of rows with no duplicates nor missing values.
18
 
18
 
19
  For convenience, these are generic functions for which users can write
19
  There are generic functions for getting and setting row names,
20
  other methods, and there are default methods for arrays.  The
20
  with default methods for arrays.
21
  description here is for the \code{data.frame} method.
21
  The description here is for the \code{data.frame} method.
22
 
22
 
23
  \code{`.rowNamesDF<-`} is a (non-generic replacement) function to set
23
  \code{`.rowNamesDF<-`} is a (non-generic replacement) function to set
24
  row names for data frames, with extra argument \code{make.names}.
24
  row names for data frames, with extra argument \code{make.names}.
25
  This function only exists as workaround as we cannot easily change the
25
  This function only exists as workaround as we cannot easily change the
26
  \code{row.names<-} generic without breaking legacy code in existing packages.
26
  \code{row.names<-} generic without breaking legacy code in existing packages.
Line 75... Line 75...
75
  deparsing but never via \code{row.names} or
75
  deparsing but never via \code{row.names} or
76
  \code{\link{attr}(x, "row.names")}.  Additionally, some names of this
76
  \code{\link{attr}(x, "row.names")}.  Additionally, some names of this
77
  sort are marked as \sQuote{automatic} and handled differently by
77
  sort are marked as \sQuote{automatic} and handled differently by
78
  \code{\link{as.matrix}} and \code{\link{data.matrix}} (and potentially
78
  \code{\link{as.matrix}} and \code{\link{data.matrix}} (and potentially
79
  other functions).  (All zero-row data frames are regarded as having
79
  other functions).  (All zero-row data frames are regarded as having
80
  automatic row.names.)
80
  automatic row names.)
81
}
81
}
82
\references{
82
\references{
83
  Chambers, J. M. (1992)
83
  Chambers, J. M. (1992)
84
  \emph{Data for models.}
84
  \emph{Data for models.}
85
  Chapter 3 of \emph{Statistical Models in S}
85
  Chapter 3 of \emph{Statistical Models in S}
Line 88... Line 88...
88
\seealso{
88
\seealso{
89
  \code{\link{data.frame}}, \code{\link{rownames}}, \code{\link{names}}.
89
  \code{\link{data.frame}}, \code{\link{rownames}}, \code{\link{names}}.
90
 
90
 
91
  \code{.row_names_info} for the internal representations.
91
  \code{.row_names_info} for the internal representations.
92
}
92
}
-
 
93
\examples{
-
 
94
## To illustrate the note:
-
 
95
df <- data.frame(x = c(TRUE, FALSE, NA, NA), y = c(12, 34, 56, 78))
-
 
96
row.names(df) <- 1 : 4
-
 
97
attr(df, "row.names")
-
 
98
deparse(df)
-
 
99
## (Compact storage, not regarded as automatic.)
-
 
100
row.names(df) <- NULL
-
 
101
attr(df, "row.names")
-
 
102
deparse(df)
-
 
103
## (Compact storage, regarded as automatic.)
-
 
104
}
93
\keyword{classes}
105
\keyword{classes}
94
\keyword{methods}
106
\keyword{methods}