0

I have a data set where people select the activities that they participated (0,1). Then they are asked what was the most important activity. I need a table which lists the percentage of people who said activity x was % most valuable. The tricky thing is that for each activity I need to re-run the table selecting only people who participated in activity x amd then grabbing the percentage in the highest category from this table and putting this value into another table.

I can subset the data so it only has people who participated in activity x and then run a table with percentages. In this case I would run the table three times. But I have no clue how to get the final table based on these elements?

In the end the table needs to look like this:
    rated most valuable
activity x    x.x%
activity y    x.x%
activity z    x.x%
M.Wu
  • 1
  • need a reproducible example – AdamO Aug 09 '19 at 20:33
  • 1
    Please make this question *reproducible*. This includes sample code you've tried (including listing non-base R packages), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and expected output. Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Aug 09 '19 at 20:33
  • I have only made it to this point:#subset data sub_reserach = subset(d2, Part_UGradResearch == 1) sub_IntEx = subset(d, Part_IntlExp == 1) sub_Lead = subset(d, Part_Leadership == 1) #run freq's for same variable but with different dataset. MostValuableUniversity_reserach = gen_table(sub_reserach,"MostValuableUniversity",newname="Response")[,-2] MostValuableUniversity_IntEx = gen_table(sub_IntEx,"MostValuableUniversity",newname="Response")[,-2] MostValuableUniversity_Lead = gen_table(sub_Lead,"MostValuableUniversity",newname="Response")[,-2] – M.Wu Aug 09 '19 at 20:45
  • well I am not sure how to provide something reproducible.... – M.Wu Aug 09 '19 at 20:48
  • It will help greatly if you could provide a small set of sample data. Use the function `dput()` on a subset of your data or a sample set. – David O Aug 09 '19 at 20:56

0 Answers0