"tbl" 在 R 中代表什么(例如在 dplyr 包中)?

What does "tbl" stand for in R (for example in dplyr package)?

dplyr 包中,他们讨论 tbl、如何加入他们等等。

我到处寻找 tbl 的解释,但找不到任何有用的东西。

我怀疑这个术语不仅在 dplyr 包中使用,但以防万一我会让你知道在使用 dplyr.[=18 时碰到它=]

我不知道这是什么意思所以我的问题是:

tbl 代表什么(在 dplyr 包中或一般情况下)?

tbl = table

在 dlplyr 中有几种类型的 tables :

join ==> 将两个表连接在一起。

join.tbl_df ==>加入数据框 tbls.

join.tbl_dt ==>加入数据table tbls.

join.tbl_sql ==>加入sql tbls.

实际上很难找到关于这个主题的信息。 tbl/is.tbl 的文档提供的信息很少。

据我所知,tbl 是 dplyr 函数作为数据参数接收的表格数据的通用 class。

创建一个 tbl 前缀 "tbl_" 到 class 名称。来自 dplyr/tbl.r:

#' Create a "tbl" object
#'
#' `tbl()` is the standard constructor for tbls. `as.tbl()` coerces,
#' and `is.tbl()` tests.
#'
#' @keywords internal
#' @export
#' @param subclass name of subclass. "tbl" is an abstract base class, so you
#'   must supply this value. `tbl_` is automatically prepended to the
#'   class name
#' @param object to test/coerce.
#' @param ... For `tbl()`, other fields used by class. For `as.tbl()`,
#'   other arguments passed to methods.
#' @examples
#' as.tbl(mtcars)
make_tbl <- function(subclass, ...) {
  subclass <- paste0("tbl_", subclass)
  structure(list(...), class = c(subclass, "tbl"))

在 data.frame 上使用任何 dplyr 函数(连接、select、变异等)返回 data.frame。

library(dplyr)
select(mtcars, cyl) %>% class

但是,在 tbl_df/tibble 上调用 dplyr 函数(参见 )返回 tbl_df/tibble。

> select(tbl_df(mtcars), cyl) %>% class
[1] "tbl_df"     "tbl"        "data.frame"

这里我们看到tbl_df继承自tbl,后者继承自data.frame

我认为是 tibble

The tbl_df class is a subclass of data.frame, created in order to have different default behaviour. The colloquial term "tibble" refers to a data frame that has the tbl_df class. Tibble is the central data structure for the set of packages known as the tidyverse, including dplyr, ggplot2, tidyr, and readr.