Calculate Median Age - Considering Distinct Count of Variable in another Variable

Not bad. To do it more easily you can use a reprex. See the FAQ. Cut and paste the output from your data.frame, say d

# install .packages("reprex") if you don't already have it
# create or read in the data frame, then
dput(d)

and then paste and result in a post. That's it.

I'll come back to address the main question.

structure(list(id = c("AXT123", "AXR456", "AXV678", "AXC789", 
"AXB123", "AXT124", "AXV345", "AXC890", "AXC123", "AXC345", "AXV643", 
"AXQ876", "AXW345", "AXE987", "AXY678", "AXT098", "AXE345", "AXT945", 
"AXN267", "AXP345"), Top50 = c("Congenital_heart_conditions", 
"Abdominal_Pain", "Chest_Pain", "Cough", "Viral_infection", "Cough", 
"Cough", "Viral_infection", "Dehydration", "Abdominal_Pain", 
"Congenital_heart_conditions", "Diabetes", "Diabetes_2", "Infection_1", 
"Infection_2", "Infection_3", "Infection_4", "Infection_5", "Cancer", 
"ngenital_heart_conditions"), Age = c(5, 54, 23, 44, 12, 15, 
83, 18, 22, 61, 2, 55, 8, 37, 71, 11, 1, 1, 28, 3)), class = "data.frame", row.names = c(NA, 
-20L))