Why am I getting an error that an object is not found when it is a column name

I am working on a course assignment on coursera and keep running into an error in one of the steps.
"hotel" is a column name in my dataset (which is an object already) and I am trying to reference it in a filter function but the error says hotel is not found
Here is the code:
onlineta_city_hotels <- filter(hotel_bookings,
(hotel=="City Hotel" &
hotel_bookings$market_segment=="Online TA"))

Any help is appreciated I am a beginner on R.

Omit the parens, which cause the == to be evaluated before filter. Also, pipes are preferred

onlineta_city_hotels <- hotel_bookings %>% filter(hotel == "City Hotel" & market_segment=="Online TA")

Thank you I will try to become more comfortable using pipes

Pipes are purely a matter of taste, particularly when there is only one piping step.

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.