DPLYR not recognizing a column that is in my dataframe

Hello. I'm using dplyr to summarise a larger data frame. I get an error that states `Error in group_by(RATING_CLASS_CODE): object 'RATING_CLASS_CODE' not found.

Here is the code I'm using:

class_comp <- mc_lr_segments_q22018 %>%
  select(RATING_CLASS_CODE)
  group_by(RATING_CLASS_CODE) %>%
  summarise(sum(earned), sum(incurred))

EDIT: I figured out why. I would delete but I don't have permission to. I forgot the pipe operator. Here is the code that worked:

class_comp <- mc_lr_segments_q22018 %>%
  select(RATING_CLASS_CODE) **%>%**
  group_by(RATING_CLASS_CODE) %>%
  summarise(sum(earned), sum(incurred))

Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.reprex("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ, linked to below.

1 Like

Hi Mara. I apologize. I just figured out why and WHILE I'm embarrassed, it has to do with a missing pipe operator after the select statement. So much for my first question on the community being a good one.

No worries!

If your question's been answered (even if by you), would you mind choosing a solution? (See FAQ below for how).

Having questions checked as resolved makes it a bit easier to navigate the site visually and see which threads still need help.

Thanks

1 Like

Consider it a test run :grin: You’ve even gotten a reprex nudge, so now you know how to make your next question super awesome!