You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't mention iris dataset in documentation (#752)
* Removed iris from dataset.xlsx
* Removed iris from datasets.xls
* Remove mention of iris in README files #642
* Removed mentioning of iris in vignettes, using mtcars instead
* Updated examples to refer to new mtcars instead of iris
* Updated example to better illustrate example in helpfile
* Whitespace
---------
Co-authored-by: Jenny Bryan <[email protected]>
Copy file name to clipboardExpand all lines: README.Rmd
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ Specify a worksheet by name or number.
93
93
94
94
```{r}
95
95
read_excel(xlsx_example, sheet = "chickwts")
96
-
read_excel(xls_example, sheet = 4)
96
+
read_excel(xls_example, sheet = 3)
97
97
```
98
98
99
99
There are various ways to control which cells are read. You can even specify the sheet here, if providing an Excel-style cell range.
@@ -109,7 +109,7 @@ read_excel(xlsx_example, range = "mtcars!B1:D5")
109
109
If `NA`s are represented by something other than blank cells, set the `na` argument.
110
110
111
111
```{r}
112
-
read_excel(xlsx_example, na = "setosa")
112
+
read_excel(xlsx_example, na = "0")
113
113
```
114
114
115
115
If you are new to the tidyverse conventions for data import, you may want to consult the [data import chapter](https://r4ds.had.co.nz/data-import.html) in R for Data Science. readxl will become increasingly consistent with other packages, such as [readr](https://readr.tidyverse.org/).
@@ -149,7 +149,7 @@ Here are some other packages with functionality that is complementary to readxl
149
149
__Writing Excel files__: The example files `datasets.xlsx` and `datasets.xls` were created with the help of [openxlsx](https://CRAN.R-project.org/package=openxlsx) (and Excel). openxlsx provides "a high level interface to writing, styling and editing worksheets".
Why does this work? `readr::write_csv()` is a well-mannered "write" function: it does its main job *and returns its input invisibly*. The above command reads the iris sheet from readxl's `datasets.xlsx` example workbook and caches a CSV version of the resulting data frame to file.
60
60
61
61
Let's check. Did we still import the data? Did we write the CSV file?
62
62
63
63
```{r}
64
-
iris_xl
65
-
dir(pattern = "iris")
64
+
mtcars_xl
65
+
dir(pattern = "mtcars")
66
66
```
67
67
68
68
Yes! Is the data written to CSV an exact copy of what we imported from Excel?
69
69
70
70
```{r}
71
-
iris_alt <- read_csv("iris-raw.csv")
71
+
mtcars_alt <- read_csv("mtcars-raw.csv")
72
72
## readr leaves a note-to-self in `spec` that records its column guessing,
73
73
## so we remove that attribute before the check
74
-
attr(iris_alt, "spec") <- NULL
75
-
identical(iris_xl, iris_alt)
74
+
attr(mtcars_alt, "spec") <- NULL
75
+
identical(mtcars_xl, mtcars_alt)
76
76
```
77
77
78
78
Yes! If we needed to restart or troubleshoot this fictional analysis, `iris-raw.csv` is available as a second, highly accessible alternative to `datasets.xlsx`.
@@ -193,11 +193,11 @@ Rework examples from above but using base R only, other than readxl.
0 commit comments