General question about prop.table function in R

Hello - I am using the following sample code to get distribution of patients with different lymph node (N stage) status in a given clinical dataset

prop.table(table(dataframe$Cohort=="A", dataframe$Nstage)) %>% *(100) %>% round(2)

I get a result which looks something like this:Screen Shot 2020-07-25 at 2.35.36 PM

However, I would like my results to add up to a 100% and not divided into False and True categories. The result I am looking for should appear like this (just an example):

0    1    2   Missing
20   60   20     0

Is there a way to edit the prop.table function in order to get this result?

Thanks!

1 Like

Hey there, if you want to keep the same syntax, try removing the first argument in table()

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.