invalid argument to unary operator

Hi everyone.

I'm very new to learning R and I've run into this error while trying to delete columns. Below is the code I'm using.

all_trips <- all_trips >%>
Error: unexpected input in "all_trips <- all_trips >%>"
select(-c(start_lat, start_lng, end_lat, end_lng, birthyear ,gender ,"01 - Rental Details Duration In Seconds Uncapped" ,"05 - Member Details Member Birthday Year" ,"Member Gender" ,tripduration))
Error in select(-c(start_lat, start_lng, end_lat, end_lng, birthyear, :
object 'start_lat' not found

I've double checked that the columns exist. When I run it like this, I end up with "object 'start_lat' not found". When I put all column names in " ", I get the error "invalid argument to unary operator".

I also tried to code it in a different way, but got the same error.

all_trips <- subset(all_trips, select = -c(start_lat, start_lng, end_lat, end_lng, birthyear, gender, "01 - Rental Details Duration In Seconds Uncapped", "05 - Member Details Member Birthday Year", "Member Gender", "tripduration"))
Error in -c(start_lat, start_lng, end_lat, end_lng, birthyear, gender, :
invalid argument to unary operator

Since I'm still new and learning, this is only just practice. But any help will be highly appreciated.

Thank you.

The pipe operator is %>% not >%> :grinning:

Thank you! Clearly time for me to go to sleep lol

Also, invalid column names should be placed inside of back ticks not double quotes. Use

`01 - Rental Details`

not "01 - Rental Details". The back tick key is to the left of the 1 key on a US keyboard.

Thank you. I'll keep that in mind.

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.