Pipe coding mistake

my_data %>%
select(gender, cholesterol, cardio) %>%
filter(gender <2) %>%

after this I hit run and nothing happens, i get this;

could not find function "%>%"

my_data %>%

  • select(gender, cholesterol, cardio) %>%
  • filter(gender <2) %>%
  • View
    Error in my_data %>% select(gender, cholesterol, cardio) %>% filter(gender < :
    could not find function "%>%"

Have you run library(dplyr) before running your code?

how do i use library(dplyr)?

You don't end with a pipe. %>% is a pipe, after a pipe R looks for a function to run and can't find one, hence the error.

1 Like

Have you tried it without the trailing pipe? For example:

my_data %>%
select(gender, cholesterol, cardio) %>%
filter(gender <2)

Edit: Looks like @JonesYaniv just beat me to it!

1 Like

This topic was automatically closed 42 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.