Question: R Programming coding by using RStudio: Part 1) Load table2 from tidyverse package. Compute the rate for table2. You need to do the following operations:
R Programming coding by using RStudio:
Part 1)
Load table2 from tidyverse package. Compute the rate for table2. You need to do the following operations:
1. tidy table 2;
2. calculate the rate by dividing cases by population;
3. build a new tibble with additional variable: rate.
Part 2)
Load the who data from tidyverse. Read the following meta info for the column names:
a. The first three letters of each column denote whether the column contains new or old cases of TB. In this dataset, each column contains new cases.
b. The next two or three letters describe the type of TB: rel stands for cases of relapse; ep stands for cases of extrapulmonary TB; sn stands for cases of pulmonary TB that could not be diagnosed by a pulmonary smear (smear negative); sp stands for cases of pulmonary TB that could be diagnosed be a pulmonary smear (smear positive).
c. The sixth letter gives the sex of TB patients. The dataset groups cases by males (m) and females (f).
d. The remaining numbers gives the age group. The dataset groups cases into seven age groups: 014 = 0 - 14 years old; 1524 = 15 - 24 years old; 2534 = 25 - 34 years old; 3544 = 35 - 44 years old; 4554 = 45 - 54 years old; 5564 = 55 - 64 years old; 65 = 65 or older.
Tidy the data:
1. Longer the tibble by converting the column names new_sp_m014:newrel_f65 to values of a variable (for example key),
2. Find and correct the inconsistency, i.e., newrel -> new_rel
3. Extract type, sex, and age information from key variable and build a variable for each of them. Also, remove redundant variables.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
