Fungsi data.frame() membuat bingkai data, kumpulan variabel yang digabungkan erat yang memiliki banyak properti matriks dan daftar, digunakan sebagai struktur data mendasar oleh sebagian besar perangkat lunak pemodelan R.
data.frame(…, row.names = NULL, check.rows = FALSE,
check.names = TRUE, fix.empty.names = TRUE,
stringsAsFactors = default.stringsAsFactors())<p></p><p>default.stringsAsFactors()</p>
| Parameter | Deskripsi |
|---|---|
… |
these arguments are of either the form value or tag = value. Component names are created based on the tag (if present) or the deparsed argument itself. |
row.names |
NULL or a single integer or character string specifying a column to be used as row names, or a character or integer vector giving the row names for the data frame. |
check.rows |
if TRUE then the rows are checked for consistency of length and names. |
check.names |
logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names and are not duplicated. If necessary they are adjusted (by make.names) so that they are. |
fix.empty.names |
logical indicating if arguments which are “unnamed” (in the sense of not being formally called as someName = arg) get an automatically constructed name or rather name "". Needs to be set to FALSE even when check.names is false if "" names should be kept. |
stringsAsFactors |
logical: should character vectors be converted to factors? The ‘factory-fresh’ default is TRUE, but this can be changed by setting options(stringsAsFactors = FALSE). |
# NOT RUN {
L3 <- LETTERS[1:3]
fac <- sample(L3, 10, replace = TRUE)
(d <- data.frame(x = 1, y = 1:10, fac = fac))
## The "same" with automatic column names:
data.frame(1, 1:10, sample(L3, 10, replace = TRUE))
is.data.frame(d)
## do not convert to factor, using I() :
(dd <- cbind(d, char = I(letters[1:10])))
rbind(class = sapply(dd, class), mode = sapply(dd, mode))
stopifnot(1:10 == row.names(d)) # {coercion}
(d0 <- d[, FALSE]) # data frame with 0 columns and 10 rows
(d.0 <- d[FALSE, ]) # <0 rows> data frame (3 named cols)
(d00 <- d0[FALSE, ]) # data frame with 0 columns and 0 rows
# }