Filter turning characters into numeric

Hello - As someone new to R, I suspect I'm missing something basic, but can't figure out what. I'm hoping someone here can help.

I'm trying to group data, and then filter to remove certain groups. It sort of works. So:

> bob <- group_by(cwm, ordernumber,description,customer)

Does the grouping properly.

>NoLocal <- filter(bob,"description"!="Local Delivery")

Doesn't give me any errors, but it changes all the columns that were chr into numeric ones.

Part of Bob looks like:

However, NoLocal, which I was expecting to just remove all groups that had "Local Delivery" as one of the items, looks like this:

Any and all help appreciated!
Many thanks!

A reproducible example would be useful here:
FAQ: What's a reproducible example (reprex) and how do I create one?

Without having access to the columns you're using, I can only say that one uses dplyr::filter() with unquoted columns. So your script may look something like:

cwm %>%
    group_by(ordernumber, description, customer) %>%
    filter(description != "Local Delivery")

Is it possible you aren't using dplyr's filter somehow? stats::filter() returns something similar to your data frame of V1, V2, etc.

If you explicity call dplyr::filter() do you get the same issue?

Thank you! I shall read up on the reprex and make sure to use that next time I have a question.

(And I had been doing it without the quotes around 'description' - had tried that again at one point, although I didn't think it was correct, and then copied the wrong line.)

But yes - you were correct - for some reason, it wasn't using dplyr's filter.

Specifying dplyr::filter gives me back my columns. Not sure I've filtered how I meant to, but that's a different issue, and one I'll hopefully sort.

Thank you again!
Chris

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.