Skip to content

Commit ee615de

Browse files
use mtcarz data
1 parent eab86d5 commit ee615de

39 files changed

+742
-267
lines changed

R/ds-cross-table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#' @section Deprecated Function:
3030
#' \code{ds_cross_table()} has been deprecated. Instead use \code{ds_cross_table()}.
3131
#' @examples
32-
#' k <- ds_cross_table(mtcars, cyl, am)
32+
#' k <- ds_cross_table(mtcarz, cyl, am)
3333
#' k
3434
#'
3535
#' # bar plots

R/ds-data-mtcarz.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#' mtcarz
2+
#'
3+
#' Copy of mtcars data set with modified variable types
4+
#'
5+
"mtcarz"

R/ds-describe.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#' @section Deprecated function:
1313
#' \code{tailobs()} has been deprecated. Instead use \code{ds_tailobs()}.
1414
#' @examples
15-
#' ds_tailobs(mtcars$mpg, 5)
16-
#' ds_tailobs(mtcars$mpg, 5, type = "high")
15+
#' ds_tailobs(mtcarz$mpg, 5)
16+
#' ds_tailobs(mtcarz$mpg, 5, type = "high")
1717
#' @export
1818
#' @seealso \code{\link[dplyr]{top_n}}
1919
#'

R/ds-freq-cont.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
#' \code{freq_cont()} has been deprecated. Instead use \code{ds_freq_cont()}.
2828
#' @examples
2929
#' # frequency table
30-
#' ds_freq_cont(mtcars, mpg, 4)
30+
#' ds_freq_cont(mtcarz, mpg, 4)
3131
#'
3232
#' # histogram
33-
#' k <- ds_freq_cont(mtcars, mpg, 4)
33+
#' k <- ds_freq_cont(mtcarz, mpg, 4)
3434
#' hist(k)
3535
#' @seealso \code{link{ds_freq_table}} \code{link{ds_cross_table}}
3636
#' @export

R/ds-freq-table.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
#' \code{freq_table()} has been deprecated. Instead use \code{ds_freq_table()}.
2121
#' @examples
2222
#' # frequency table
23-
#' mt <- mtcars
24-
#' mt$cyl <- as.factor(mt$cyl)
25-
#' ds_freq_table(mt, cyl)
23+
#' ds_freq_table(mtcarz, cyl)
2624
#'
2725
#' # barplot
28-
#' mt <- mtcars
29-
#' mt$cyl <- as.factor(mt$cyl)
30-
#' k <- ds_freq_table(mt, cyl)
26+
#' k <- ds_freq_table(mtcarz, cyl)
3127
#' barplot(k)
3228
#' @seealso \code{link{ds_freq_cont}} \code{link{ds_cross_table}}
3329
#' @export

R/ds-group-summary.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
#' use \code{ds_group_summary()}.
2525
#' @examples
2626
#' # ds_group summary
27-
#' mt <- mtcars
28-
#' mt$cyl <- as.factor(mt$cyl)
29-
#' ds_group_summary(mt, cyl, mpg)
27+
#' ds_group_summary(mtcarz, cyl, mpg)
3028
#'
3129
#' # boxplot
32-
#' k <- ds_group_summary(mt, cyl, mpg)
30+
#' k <- ds_group_summary(mtcarz, cyl, mpg)
3331
#' boxplot(k)
3432
#' @seealso \code{link{ds_summary_stats}}
3533
#' @export

R/ds-mult-table.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
#' \code{oway_tables()} and \code{tway_tables()} have been deprecated. Instead
1414
#' use \code{ds_oway_tables()} and \code{ds_tway_tables()}.
1515
#' @examples
16-
#' mt <- mtcars
17-
#' mt[, c(2, 8, 9)] <- lapply(mt[, c(2, 8, 9)], factor)
1816
#' # multiple one way tables
19-
#' ds_oway_tables(mt)
17+
#' ds_oway_tables(mtcarz)
2018
#'
2119
#' # multiple two way tables
22-
#' ds_tway_tables(mt)
20+
#' ds_tway_tables(mtcarz)
2321
#' @seealso \code{link{ds_freq_table}} \code{link{ds_cross_table}}
2422
#' @export
2523
#'

R/ds-multistats.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' @section Deprecated Function:
1010
#' \code{multistats()} has been deprecated. Instead use \code{ds_multi_stats()}
1111
#' @examples
12-
#' ds_multi_stats(mtcars, mpg, disp, hp)
12+
#' ds_multi_stats(mtcarz, mpg, disp, hp)
1313
#' @export
1414
#'
1515
ds_multi_stats <- function(x, ...) {

R/ds-screener.R

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@
3232
#' use \code{ds_screener()}.
3333
#' @examples
3434
#' # screen data
35-
#' mt <- mtcars
36-
#' mt[, c(2, 8:11)] <- lapply(mt[, c(2, 8:11)], factor)
37-
#' mt[sample(1:nrow(mt), 12), sample(1:ncol(mt), 6)] <- NA
38-
#' ds_screener(mt)
39-
#'
40-
#' # visualize missing data
41-
#' k <- ds_screener(mt)
42-
#' plot(k)
35+
#' ds_screener(mtcarz)
4336
#' @export
4437
#'
4538
ds_screener <- function(y) UseMethod('ds_screener')

R/ds-summary-stats.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#' \code{summary_stats()} has been deprecated. Instead use
4343
#' \code{ds_summary_stats()}.
4444
#' @examples
45-
#' ds_summary_stats(mtcars, mpg)
45+
#' ds_summary_stats(mtcarz, mpg)
4646
#' @seealso \code{\link[base]{summary}} \code{\link{ds_freq_cont}}
4747
#' \code{\link{ds_freq_table}} \code{\link{ds_cross_table}}
4848
#' @export
@@ -111,7 +111,6 @@ ds_summary_stats.default <- function(data, variable) {
111111
summary_stats <- function(data) {
112112

113113
.Deprecated("ds_summary_stats()")
114-
# ds_summary_stats(data)
115114

116115
}
117116

README.Rmd

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,51 @@ Use `ds_launch_shiny_app()` to explore the package using a shiny app.
7474

7575
## Usage
7676

77-
##### Summary Statistics
77+
We will use a modified version of the `mtcars` data set in the below examples. The only difference between the data sets is related to the
78+
variable types.
7879

7980
```{r load, eval=TRUE, echo=FALSE}
8081
library(descriptr)
81-
mtcars$cyl <- as.factor(mtcars$cyl)
8282
```
8383

84+
```{r egdata}
85+
str(mtcarz)
86+
```
87+
88+
##### Summary Statistics
89+
8490
```{r descript1}
85-
ds_summary_stats(mtcars, mpg)
91+
ds_summary_stats(mtcarz, mpg)
8692
```
8793

8894
##### Two Way Table
8995

9096
```{r descript2}
91-
ds_cross_table(mtcars, cyl, gear)
97+
ds_cross_table(mtcarz, cyl, gear)
9298
```
9399

94100
##### One Way Table
95101

96102
```{r descript3}
97-
mt <- mtcars
98-
mt$cyl <- as.factor(mt$cyl)
99-
ds_freq_table(mt, cyl)
103+
ds_freq_table(mtcarz, cyl)
100104
```
101105

102106
##### One Way Table (Continuous Data)
103107

104108
```{r descript4}
105-
ds_freq_cont(mtcars, mpg)
109+
ds_freq_cont(mtcarz, mpg)
106110
```
107111

108112
##### Group Summary
109113

110114
```{r descript5}
111-
mt <- mtcars
112-
mt$cyl <- as.factor(mt$cyl)
113-
ds_group_summary(mt, cyl, mpg)
115+
ds_group_summary(mtcarz, cyl, mpg)
114116
```
115117

116118
##### Multiple Variable Statistics
117119

118120
```{r descriptr6}
119-
ds_multi_stats(mtcars, mpg, disp, hp)
121+
ds_multi_stats(mtcarz, mpg, disp, hp)
120122
```
121123

122124

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,30 @@ Use `ds_launch_shiny_app()` to explore the package using a shiny app.
6464

6565
## Usage
6666

67+
We will use a modified version of the `mtcars` data set in the below
68+
examples. The only difference between the data sets is related to the
69+
variable types.
70+
71+
``` r
72+
str(mtcarz)
73+
#> 'data.frame': 32 obs. of 11 variables:
74+
#> $ mpg : num 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
75+
#> $ cyl : Factor w/ 3 levels "4","6","8": 2 2 1 2 3 2 3 1 1 2 ...
76+
#> $ disp: num 160 160 108 258 360 ...
77+
#> $ hp : num 110 110 93 110 175 105 245 62 95 123 ...
78+
#> $ drat: num 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
79+
#> $ wt : num 2.62 2.88 2.32 3.21 3.44 ...
80+
#> $ qsec: num 16.5 17 18.6 19.4 17 ...
81+
#> $ vs : Factor w/ 2 levels "0","1": 1 1 2 2 1 2 1 2 2 2 ...
82+
#> $ am : Factor w/ 2 levels "0","1": 2 2 2 1 1 1 1 1 1 1 ...
83+
#> $ gear: Factor w/ 3 levels "3","4","5": 2 2 2 1 1 1 1 2 2 2 ...
84+
#> $ carb: Factor w/ 6 levels "1","2","3","4",..: 4 4 1 1 2 1 4 2 2 4 ...
85+
```
86+
6787
##### Summary Statistics
6888

6989
``` r
70-
ds_summary_stats(mtcars, mpg)
90+
ds_summary_stats(mtcarz, mpg)
7191
#> Univariate Analysis
7292
#>
7393
#> N 32.00 Variance 36.32
@@ -110,7 +130,7 @@ ds_summary_stats(mtcars, mpg)
110130
##### Two Way Table
111131

112132
``` r
113-
ds_cross_table(mtcars, cyl, gear)
133+
ds_cross_table(mtcarz, cyl, gear)
114134
#> Cell Contents
115135
#> |---------------|
116136
#> | Frequency |
@@ -149,9 +169,7 @@ ds_cross_table(mtcars, cyl, gear)
149169
##### One Way Table
150170

151171
``` r
152-
mt <- mtcars
153-
mt$cyl <- as.factor(mt$cyl)
154-
ds_freq_table(mt, cyl)
172+
ds_freq_table(mtcarz, cyl)
155173
#> Variable: cyl
156174
#> |--------------------------------------------------------------------------|
157175
#> | Cumulative Cumulative |
@@ -168,7 +186,7 @@ ds_freq_table(mt, cyl)
168186
##### One Way Table (Continuous Data)
169187

170188
``` r
171-
ds_freq_cont(mtcars, mpg)
189+
ds_freq_cont(mtcarz, mpg)
172190
#> Variable: mpg
173191
#> |-----------------------------------------------------------------------|
174192
#> | Bins | Frequency | Cum Frequency | Percent | Cum Percent |
@@ -188,9 +206,7 @@ ds_freq_cont(mtcars, mpg)
188206
##### Group Summary
189207

190208
``` r
191-
mt <- mtcars
192-
mt$cyl <- as.factor(mt$cyl)
193-
ds_group_summary(mt, cyl, mpg)
209+
ds_group_summary(mtcarz, cyl, mpg)
194210
#> mpg by cyl
195211
#> -----------------------------------------------------------------------------------------
196212
#> | Statistic/Levels| 4| 6| 8|
@@ -217,7 +233,7 @@ ds_group_summary(mt, cyl, mpg)
217233
##### Multiple Variable Statistics
218234

219235
``` r
220-
ds_multi_stats(mtcars, mpg, disp, hp)
236+
ds_multi_stats(mtcarz, mpg, disp, hp)
221237
#> # A tibble: 3 x 16
222238
#> vars min max mean t_mean median mode range variance stdev skew
223239
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ reference:
107107
illustrate the functions as well as for running tests.
108108
contents:
109109
- hsb
110+
- mtcarz

data/mtcarz.rda

1.33 KB
Binary file not shown.

0 commit comments

Comments
 (0)