Skip to content

Commit ff96e9a

Browse files
committed
adding crew column to titanic data
1 parent 905eb80 commit ff96e9a

File tree

6 files changed

+5
-9
lines changed

6 files changed

+5
-9
lines changed

R/data.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#' @format A data frame with 2201 rows and 4 variables:
88
#'
99
#' - **Class**: Passenger class ("1st", "2nd", "3rd") or crew status ("Crew")
10+
#' - **Crew**: Boolean as to whether or not a crew member (TRUE) or not (FALSE)
1011
#' - **Sex**: Sex of individual ("Male" or "Female")
1112
#' - **Age**: Categorized age ("Adult" or "Child")
1213
#' - **Survived**: Whether or not individual survived ("Yes" or "No")

README.Rmd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Next create a object with S3 class `twoxtwo`. For this example, use the `twoxtwo
5757
```{r}
5858
crew_2x2 <-
5959
titanic %>%
60-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
6160
twoxtwo(.data = ., exposure = Crew, outcome = Survived)
6261
6362
crew_2x2
@@ -73,19 +72,16 @@ Each effect measure can also be calculated without first creating the `twoxtwo`
7372

7473
```{r}
7574
titanic %>%
76-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
7775
odds_ratio(.data = ., exposure = Crew, outcome = Survived)
7876
```
7977

8078
```{r}
8179
titanic %>%
82-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
8380
risk_ratio(.data = ., exposure = Crew, outcome = Survived)
8481
```
8582

8683
```{r}
8784
titanic %>%
88-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
8985
risk_diff(.data = ., exposure = Crew, outcome = Survived)
9086
```
9187

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ must each be binary variables:
5353
``` r
5454
crew_2x2 <-
5555
titanic %>%
56-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
5756
twoxtwo(.data = ., exposure = Crew, outcome = Survived)
5857

5958
crew_2x2
@@ -97,7 +96,6 @@ Each effect measure can also be calculated without first creating the
9796

9897
``` r
9998
titanic %>%
100-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
10199
odds_ratio(.data = ., exposure = Crew, outcome = Survived)
102100
# # A tibble: 1 x 6
103101
# measure estimate ci_lower ci_upper exposure outcome
@@ -107,7 +105,6 @@ titanic %>%
107105

108106
``` r
109107
titanic %>%
110-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
111108
risk_ratio(.data = ., exposure = Crew, outcome = Survived)
112109
# # A tibble: 1 x 6
113110
# measure estimate ci_lower ci_upper exposure outcome
@@ -117,7 +114,6 @@ titanic %>%
117114

118115
``` r
119116
titanic %>%
120-
mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE)) %>%
121117
risk_diff(.data = ., exposure = Crew, outcome = Survived)
122118
# # A tibble: 1 x 6
123119
# measure estimate ci_lower ci_upper exposure outcome

data-raw/datasets.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ titanic <-
55
## convert to tibble
66
dplyr::as_tibble() %>%
77
## expand counts
8-
tidyr::uncount(n)
8+
tidyr::uncount(n) %>%
9+
## create crew variable
10+
dplyr::mutate(Crew = ifelse(Class == "Crew", TRUE, FALSE), .after = "Class")
911

1012
usethis::use_data(titanic, overwrite = TRUE)

data/titanic.rda

35 Bytes
Binary file not shown.

man/titanic.Rd

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

0 commit comments

Comments
 (0)