I am trying to get Percentages, in R, with tidyverse:
- based on the first row
NSTEMIwhich regardless of its counts (compared to the following categories)is always 100 %. - Yet I want my percentages
'Seen by Cardiologist', 'Admitted to Cardiac Unit or Ward', 'Eligible for Angiography'to be calculated with reference toNSTEMI. In lay language will sound like -out of NSTEMI how much percentage have been seen by the cardiologist, admitted to cardiac unit and are eligible for angiography; - Yet, the last two rows
'Underwent Angiography' and 'Underwent Angiography Before Discharge'andtheir Percentagesto be calculated with reference to the'Eligible for Angiography'whichis my fourth row. It is like from'Eligible for Angiography' how many 'Underwent Angiography' and 'Underwent angiography before discharge'
This is my sample of data :
structure(list(Category = c("NSTEMI", "Seen by cardiologist",
"Admitted to cardiac unit or Ward", "Eligible for angiography",
"Underwent angiography", "Underwent angiography before discharge"
), Counts = c(196L, 196L, 158L, 174L, 174L, 173L)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
An example of the table I want looks as bellow picture:
As observed, the table I want is done based on my principles designed above.
