When group_by() wont group

Hi,

I'm dealing with a dataset and unfortunately for this issue I can't make a sample dataset to replicate the issue. Basically I'm organizing the data and had to deal with reducing two variable types into one and I did that with str_detect() and case_when().

When I tried then grouping it appears it did not group by this new renamed industry. As seen in the screen shot "TECH JOBS" appears twice instead of grouping.

I'm basically trying to determine in the end the percentage of "Tech Jobs" per zip_code given all jobs per zip_code.

Any ideas are welcome.

You're in great shape, because what you did so far got you employment for each industry as well as the total jobs in the industry. Now that you've grouped by zip_code and industry (you did that correctly), you need to follow up with a summarize(). Following the pipe chain you already have, try adding:

%>% summarize(percent_employment = sum(employment)/mean(total_jobs_zip)*100)

I can't check it without some kind of reprex, but I think all you're missing is the last step---summing employment across instances of "tech jobs" and then dividing by the total.

1 Like

Thank you @John_Franchak !

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.