在 R tibble 包中设置一个选项
Set an option in the R tibble package
1.4.2 版的 tibble 包具有在 tibble-options 下的文档中列出的选项。例如,一个这样的选项是 tibble.max_extra_cols,默认为 100。
如何访问和设置这些选项?
使用options
设置,getOption
检索。比如下面我们设置"tibble.print_min"
为3;然后我们证明我们确实设置了它,并将 150 行鸢尾花数据集显示为小标题,注意只显示 3 行。最后我们将 "tibble.print_min"
设置回其默认值,注意如果 getOption("tibble.print_min")
returns NULL 则意味着将使用默认值。现在显示 10 行。
library(tibble)
options(tibble.print_min = 3)
getOption("tibble.print_min")
## [1] 3
as.tibble(iris)
## # A tibble: 150 x 5
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## <dbl> <dbl> <dbl> <dbl> <fct>
## 1 5.10 3.50 1.40 0.200 setosa
## 2 4.90 3.00 1.40 0.200 setosa
## 3 4.70 3.20 1.30 0.200 setosa
## # ... with 147 more rows
options(tibble.print_min = NULL)
getOption("tibble.print_min")
## [1] NULL
as.tibble(iris)
## # A tibble: 150 x 5
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## <dbl> <dbl> <dbl> <dbl> <fct>
## 1 5.10 3.50 1.40 0.200 setosa
## 2 4.90 3.00 1.40 0.200 setosa
## 3 4.70 3.20 1.30 0.200 setosa
## 4 4.60 3.10 1.50 0.200 setosa
## 5 5.00 3.60 1.40 0.200 setosa
## 6 5.40 3.90 1.70 0.400 setosa
## 7 4.60 3.40 1.40 0.300 setosa
## 8 5.00 3.40 1.50 0.200 setosa
## 9 4.40 2.90 1.40 0.200 setosa
## 10 4.90 3.10 1.50 0.100 setosa
## # ... with 140 more rows
1.4.2 版的 tibble 包具有在 tibble-options 下的文档中列出的选项。例如,一个这样的选项是 tibble.max_extra_cols,默认为 100。
如何访问和设置这些选项?
使用options
设置,getOption
检索。比如下面我们设置"tibble.print_min"
为3;然后我们证明我们确实设置了它,并将 150 行鸢尾花数据集显示为小标题,注意只显示 3 行。最后我们将 "tibble.print_min"
设置回其默认值,注意如果 getOption("tibble.print_min")
returns NULL 则意味着将使用默认值。现在显示 10 行。
library(tibble)
options(tibble.print_min = 3)
getOption("tibble.print_min")
## [1] 3
as.tibble(iris)
## # A tibble: 150 x 5
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## <dbl> <dbl> <dbl> <dbl> <fct>
## 1 5.10 3.50 1.40 0.200 setosa
## 2 4.90 3.00 1.40 0.200 setosa
## 3 4.70 3.20 1.30 0.200 setosa
## # ... with 147 more rows
options(tibble.print_min = NULL)
getOption("tibble.print_min")
## [1] NULL
as.tibble(iris)
## # A tibble: 150 x 5
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## <dbl> <dbl> <dbl> <dbl> <fct>
## 1 5.10 3.50 1.40 0.200 setosa
## 2 4.90 3.00 1.40 0.200 setosa
## 3 4.70 3.20 1.30 0.200 setosa
## 4 4.60 3.10 1.50 0.200 setosa
## 5 5.00 3.60 1.40 0.200 setosa
## 6 5.40 3.90 1.70 0.400 setosa
## 7 4.60 3.40 1.40 0.300 setosa
## 8 5.00 3.40 1.50 0.200 setosa
## 9 4.40 2.90 1.40 0.200 setosa
## 10 4.90 3.10 1.50 0.100 setosa
## # ... with 140 more rows