当我尝试显示数据框的内容时,我得到了一些奇怪的输出(见下面的截图)。我在head()
这里使用,但对于数据框的任何显示,行为都是相同的。
该行为似乎只存在于 RStudio 中。如下所示,我的 R 基础安装按预期运行。
我的 sessionInfo 如下:
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
_LC_COLLATE=English_United States.1252_, _LC_CTYPE=English_United States.1252_, _LC_MONETARY=English_United States.1252_, _LC_NUMERIC=C_ and _LC_TIME=English_United States.1252_
attached base packages:
_stats_, _graphics_, _grDevices_, _utils_, _datasets_, _methods_ and _base_
loaded via a namespace (and not attached):
_digest_0.6.3_, _pander_0.3.8_ and _tools_3.0.1_
关于发生了什么的任何想法?
更新
作为对 Hong Ooi 的回应,我将显示以下结果getAnywhere("print.data.frame")[1:2]
。
$`package:base`
function (x, ..., digits = NULL, quote = FALSE, right = TRUE,
row.names = TRUE)
{
n <- length(row.names(x))
if (length(x) == 0L) {
cat(gettextf("data frame with 0 columns and %d rows\n",
n))
}
else if (n == 0L) {
print.default(names(x), quote = FALSE)
cat(gettext("<0 rows> (or 0-length row.names)\n"))
}
else {
m <- as.matrix(format.data.frame(x, digits = digits,
na.encode = FALSE))
if (!isTRUE(row.names))
dimnames(m)[[1L]] <- if (identical(row.names, FALSE))
rep.int("", n)
else row.names
print(m, ..., quote = quote, right = right)
}
invisible(x)
}
<bytecode: 0x0000000009f8e570>
<environment: namespace:base>
[[2]]
function (x, ..., digits = NULL, quote = FALSE, right = TRUE,
row.names = TRUE)
{
n <- length(row.names(x))
if (length(x) == 0L) {
cat(gettextf("data frame with 0 columns and %d rows\n",
n))
}
else if (n == 0L) {
print.default(names(x), quote = FALSE)
cat(gettext("<0 rows> (or 0-length row.names)\n"))
}
else {
m <- as.matrix(format.data.frame(x, digits = digits,
na.encode = FALSE))
if (!isTRUE(row.names))
dimnames(m)[[1L]] <- if (identical(row.names, FALSE))
rep.int("", n)
else row.names
print(m, ..., quote = quote, right = right)
}
invisible(x)
}
<bytecode: 0x0000000009f8e570>
<environment: namespace:base>