Skip to content

Commit e82d5fa

Browse files
authored
Merge pull request #943 from tidyverse/docs-trees
- Replace `iris` by `trees` (#943).
2 parents 756b838 + a786233 commit e82d5fa

25 files changed

+473
-276
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
213213
## Breaking changes
214214
215-
- `tibble()` now splices anonymous data frames, `tibble(tibble(a = 1), b = a)` is equivalent to `tibble(a = 1, b = a)`. This means that `tibble(iris)` now has five columns, use `tibble(iris = iris)` if the intention is to create a packed data frame (#581).
215+
- `tibble()` now splices anonymous data frames, `tibble(tibble(a = 1), b = a)` is equivalent to `tibble(a = 1, b = a)`. This means that `tibble(trees)` now has three columns, use `tibble(trees = trees)` if the intention is to create a packed data frame (#581).
216216
217217
- The `name-repair` help topic is gone, refer to `?vctrs::vec_as_names` instead.
218218

R/new.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#' new_tibble(list(a = 1:3, b = 4:6), nrow = 3)
2828
#'
2929
#' # Existing row.names attributes are ignored:
30-
#' try(validate_tibble(new_tibble(iris, nrow = 3)))
30+
#' try(validate_tibble(new_tibble(trees, nrow = 3)))
3131
#'
3232
#' # The length of all columns must be compatible with the nrow argument:
3333
#' try(validate_tibble(new_tibble(list(a = 1:3, b = 4:6), nrow = 2)))

R/print.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#' print(as_tibble(mtcars), n = 1)
4444
#' print(as_tibble(mtcars), n = 3)
4545
#'
46-
#' print(as_tibble(iris), n = 100)
46+
#' print(as_tibble(trees), n = 100)
4747
#'
4848
#' print(mtcars, width = 10)
4949
#'

R/rownames.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @examples
2626
#' # Detect row names ----------------------------------------------------
2727
#' has_rownames(mtcars)
28-
#' has_rownames(iris)
28+
#' has_rownames(trees)
2929
#'
3030
#' # Remove row names ----------------------------------------------------
3131
#' remove_rownames(mtcars) %>% has_rownames()
@@ -36,7 +36,7 @@
3636
#' column_to_rownames(mtcars_tbl, var = "car") %>% head()
3737
#'
3838
#' # Adding rowid as a column --------------------------------------------
39-
#' rowid_to_column(iris) %>% head()
39+
#' rowid_to_column(trees) %>% head()
4040
#'
4141
#' @name rownames
4242
NULL

R/tibble.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@
121121
#' )
122122
#' )
123123
#' tibble(
124-
#' a = 1:4,
125-
#' b = diag(4),
126-
#' c = cov(iris[1:4])
124+
#' a = 1:3,
125+
#' b = diag(3),
126+
#' c = cor(trees)
127127
#' )
128128
#'
129129
#' # data can not contain POSIXlt columns, or tibbles or matrices
@@ -163,7 +163,7 @@ tibble <- function(...,
163163
#' @examples
164164
#'
165165
#' # Use tibble_row() to construct a one-row tibble:
166-
#' tibble_row(a = 1, lm = lm(Petal.Width ~ Petal.Length + Species, data = iris))
166+
#' tibble_row(a = 1, lm = lm(Height ~ Girth + Volume, data = trees))
167167
tibble_row <- function(...,
168168
.name_repair = c("check_unique", "unique", "universal", "minimal")) {
169169
xs <- enquos(...)

README.Rmd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ devtools::install_github("tidyverse/tibble")
4343

4444
## Usage
4545

46+
```{r}
47+
library(tibble)
48+
```
49+
4650
Create a tibble from an existing object with `as_tibble()`:
4751

4852
```{r}
49-
library(tibble)
50-
as_tibble(iris)
53+
data <- data.frame(a = 1:3, b = letters[1:3], c = Sys.Date() - 1:3)
54+
data
55+
56+
as_tibble(data)
5157
```
5258

5359
This will work for reasonable inputs that are already data.frames, lists, matrices, or tables.

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,26 @@ If you are new to tibbles, the best place to start is the [tibbles chapter](http
2929

3030
## Usage
3131

32+
<pre class='chroma'>
33+
<span class='kr'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='o'>(</span><span class='nv'><a href='https://tibble.tidyverse.org/'>tibble</a></span><span class='o'>)</span></pre>
34+
3235
Create a tibble from an existing object with [`as_tibble()`](https://tibble.tidyverse.org/reference/as_tibble.html):
3336

3437
<pre class='chroma'>
35-
<span class='kr'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='o'>(</span><span class='nv'><a href='https://tibble.tidyverse.org/'>tibble</a></span><span class='o'>)</span>
36-
<span class='nf'><a href='https://tibble.tidyverse.org/reference/as_tibble.html'>as_tibble</a></span><span class='o'>(</span><span class='nv'>iris</span><span class='o'>)</span>
37-
<span class='c'>#&gt; <span style='color: #555555;'># A tibble: 150 × 5</span></span>
38-
<span class='c'>#&gt; <span style='font-weight: bold;'>Sepal.Length</span> <span style='font-weight: bold;'>Sepal.Width</span> <span style='font-weight: bold;'>Petal.Length</span> <span style='font-weight: bold;'>Petal.Width</span> <span style='font-weight: bold;'>Species</span></span>
39-
<span class='c'>#&gt; <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;dbl&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;fct&gt;</span> </span>
40-
<span class='c'>#&gt; <span style='color: #555555;'> 1</span> 5.1 3.5 1.4 0.2 setosa </span>
41-
<span class='c'>#&gt; <span style='color: #555555;'> 2</span> 4.9 3 1.4 0.2 setosa </span>
42-
<span class='c'>#&gt; <span style='color: #555555;'> 3</span> 4.7 3.2 1.3 0.2 setosa </span>
43-
<span class='c'>#&gt; <span style='color: #555555;'> 4</span> 4.6 3.1 1.5 0.2 setosa </span>
44-
<span class='c'>#&gt; <span style='color: #555555;'> 5</span> 5 3.6 1.4 0.2 setosa </span>
45-
<span class='c'>#&gt; <span style='color: #555555;'> 6</span> 5.4 3.9 1.7 0.4 setosa </span>
46-
<span class='c'>#&gt; <span style='color: #555555;'> 7</span> 4.6 3.4 1.4 0.3 setosa </span>
47-
<span class='c'>#&gt; <span style='color: #555555;'> 8</span> 5 3.4 1.5 0.2 setosa </span>
48-
<span class='c'>#&gt; <span style='color: #555555;'> 9</span> 4.4 2.9 1.4 0.2 setosa </span>
49-
<span class='c'>#&gt; <span style='color: #555555;'>10</span> 4.9 3.1 1.5 0.1 setosa </span>
50-
<span class='c'>#&gt; <span style='color: #555555;'># … with 140 more rows</span></span></pre>
38+
<span class='nv'>data</span> <span class='o'>&lt;-</span> <span class='nf'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span><span class='o'>(</span>a <span class='o'>=</span> <span class='m'>1</span><span class='o'>:</span><span class='m'>3</span>, b <span class='o'>=</span> <span class='nv'>letters</span><span class='o'>[</span><span class='m'>1</span><span class='o'>:</span><span class='m'>3</span><span class='o'>]</span>, c <span class='o'>=</span> <span class='nf'><a href='https://rdrr.io/r/base/Sys.time.html'>Sys.Date</a></span><span class='o'>(</span><span class='o'>)</span> <span class='o'>-</span> <span class='m'>1</span><span class='o'>:</span><span class='m'>3</span><span class='o'>)</span>
39+
<span class='nv'>data</span>
40+
<span class='c'>#&gt; a b c</span>
41+
<span class='c'>#&gt; 1 1 a 2021-07-31</span>
42+
<span class='c'>#&gt; 2 2 b 2021-07-30</span>
43+
<span class='c'>#&gt; 3 3 c 2021-07-29</span>
44+
45+
<span class='nf'><a href='https://tibble.tidyverse.org/reference/as_tibble.html'>as_tibble</a></span><span class='o'>(</span><span class='nv'>data</span><span class='o'>)</span>
46+
<span class='c'>#&gt; <span style='color: #555555;'># A tibble: 3 × 3</span></span>
47+
<span class='c'>#&gt; <span style='font-weight: bold;'>a</span> <span style='font-weight: bold;'>b</span> <span style='font-weight: bold;'>c</span> </span>
48+
<span class='c'>#&gt; <span style='color: #555555; font-style: italic;'>&lt;int&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;chr&gt;</span> <span style='color: #555555; font-style: italic;'>&lt;date&gt;</span> </span>
49+
<span class='c'>#&gt; <span style='color: #555555;'>1</span> 1 a 2021-07-31</span>
50+
<span class='c'>#&gt; <span style='color: #555555;'>2</span> 2 b 2021-07-30</span>
51+
<span class='c'>#&gt; <span style='color: #555555;'>3</span> 3 c 2021-07-29</span></pre>
5152

5253
This will work for reasonable inputs that are already data.frames, lists, matrices, or tables.
5354

man/formatting.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/new_tibble.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rownames.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)