I have a dataframe which shows a number of shops that have had a health and safety test. Within this dataframe I have the name of the shop and a factor that shows the outcome of the test on a certain day.
head(facttab)
new_table.dba_name new_table.results
1 QUICK SUB Out of Business
2 BAR BARI Pass
3 FOOD FIRST CHICAGO Pass
4 TRATTORIA ISABELLA Pass
5 DELI-TIME, L.L.C. Pass
6 GREAT AMERICAN BAGEL Fail
>
facttab <- data.frame(new_table$dba_name, new_table$results)
head(table(facttab))
new_table.dba_name Fail No Entry Not Ready Out of Business Pass Pass w/ Conditions
1 2 3 EXPRESS 1 0 0 0 0 0
1155 CAFETERIA 0 0 0 0 1 0
16TH ST FOOD MART 0 0 0 1 0 0
194 RIB JOYNT 0 1 0 0 0 0
24HR MINI MART & CELLAR FOR YOU 1 0 0 0 0 0
7-ELEVEN 0 0 0 0 4 2
I would like to build another table or dataframe that shows the % of the total outcomes of tests for each shop over the whole dataframe so I can see who has the largest % fails and the largest % pass.
The resulting table would be similar to above for example 7-Eleven would be - 0%, No Entry - 0%, Not Ready Out - 0%, Out of Business 0%, Pass - 66% and Pass w/conditions - 33%.