Conocer, instalar y activar medicaldata. Cargar la base de datos scurvy.
medicaldata (https://higgi13425.github.io/medicaldata/) es un repositorio de bases de datos de salud en R.
list.of.packages <- c("tidyverse", "janitor","rstatix","remotes", "datasets.load", "pwr", "medicaldata")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
##remotes::install_github('higgi13425/medicaldata')
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)
##
## Attaching package: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(rstatix)
##
## Attaching package: 'rstatix'
##
## The following object is masked from 'package:janitor':
##
## make_clean_names
##
## The following object is masked from 'package:stats':
##
## filter
library(remotes)
library(medicaldata)
library(datasets.load)
library(pwr)
data(package = "medicaldata")
##help("polyps",package = medicaldata)
scurvy0 <- medicaldata::scurvy %>%
clean_names()
str(scurvy0)
## tibble [12 × 8] (S3: tbl_df/tbl/data.frame)
## $ study_id : chr [1:12] "001" "002" "003" "004" ...
## $ treatment : Factor w/ 6 levels "cider","citrus",..: 1 1 3 3 6 6 5 5 2 2 ...
## $ dosing_regimen_for_scurvy: chr [1:12] "1 quart per day" "1 quart per day" "25 drops of elixir of vitriol, three times a day" "25 drops of elixir of vitriol, three times a day" ...
## $ gum_rot_d6 : Factor w/ 4 levels "0_none","1_mild",..: 3 3 2 3 4 4 4 4 2 1 ...
## $ skin_sores_d6 : Factor w/ 4 levels "0_none","1_mild",..: 3 2 4 4 4 4 4 4 2 1 ...
## $ weakness_of_the_knees_d6 : Factor w/ 4 levels "0_none","1_mild",..: 3 3 4 4 4 4 4 4 1 1 ...
## $ lassitude_d6 : Factor w/ 4 levels "0_none","1_mild",..: 3 4 4 4 4 4 4 4 2 1 ...
## $ fit_for_duty_d6 : Factor w/ 2 levels "0_no","1_yes": 1 1 1 1 1 1 1 1 1 2 ...
scurvy <- scurvy0 %>%
select(study_id, treatment,fit_for_duty_d6 )
scurvy
## # A tibble: 12 × 3
## study_id treatment fit_for_duty_d6
## <chr> <fct> <fct>
## 1 001 cider 0_no
## 2 002 cider 0_no
## 3 003 dilute_sulfuric_acid 0_no
## 4 004 dilute_sulfuric_acid 0_no
## 5 005 vinegar 0_no
## 6 006 vinegar 0_no
## 7 007 sea_water 0_no
## 8 008 sea_water 0_no
## 9 009 citrus 0_no
## 10 010 citrus 1_yes
## 11 011 purgative_mixture 0_no
## 12 012 purgative_mixture 0_no
str(scurvy)
## tibble [12 × 3] (S3: tbl_df/tbl/data.frame)
## $ study_id : chr [1:12] "001" "002" "003" "004" ...
## $ treatment : Factor w/ 6 levels "cider","citrus",..: 1 1 3 3 6 6 5 5 2 2 ...
## $ fit_for_duty_d6: Factor w/ 2 levels "0_no","1_yes": 1 1 1 1 1 1 1 1 1 2 ...
glimpse(scurvy)
## Rows: 12
## Columns: 3
## $ study_id <chr> "001", "002", "003", "004", "005", "006", "007", "008"…
## $ treatment <fct> cider, cider, dilute_sulfuric_acid, dilute_sulfuric_ac…
## $ fit_for_duty_d6 <fct> 0_no, 0_no, 0_no, 0_no, 0_no, 0_no, 0_no, 0_no, 0_no, …
summary(scurvy)
## study_id treatment fit_for_duty_d6
## Length:12 cider :2 0_no :11
## Class :character citrus :2 1_yes: 1
## Mode :character dilute_sulfuric_acid:2
## purgative_mixture :2
## sea_water :2
## vinegar :2
bd <- scurvy
bd
## # A tibble: 12 × 3
## study_id treatment fit_for_duty_d6
## <chr> <fct> <fct>
## 1 001 cider 0_no
## 2 002 cider 0_no
## 3 003 dilute_sulfuric_acid 0_no
## 4 004 dilute_sulfuric_acid 0_no
## 5 005 vinegar 0_no
## 6 006 vinegar 0_no
## 7 007 sea_water 0_no
## 8 008 sea_water 0_no
## 9 009 citrus 0_no
## 10 010 citrus 1_yes
## 11 011 purgative_mixture 0_no
## 12 012 purgative_mixture 0_no