I tried to write run code chunk in RMarkdown using ggplot2, dplyr, and ggrepel packages. Before I move my code in RMarkdown I put it in R Script, and it run smoothly. But when I tried to run it in RMarkdown they send me this message "! could not find function %>%". The code is like this:
total_industry_and_registered %>%
ggplot(aes(x=provinsi, y=jumlah_pendaftar, color=pulau, label=provinsi))+
geom_point()+
labs(title="Number of Registered Industry of Traditional Medicine by Province",
caption = "Source data: Portal Satu Data BPOM",
x="",
y="Total Industry")+
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank())+
geom_text_repel(size=3)+
theme(legend.position="bottom")
Strictly speaking %>% is a part of magrittr, which is called by dplyr. Alternatively, if you are using R version 4.1, or more recent, you can replace this with the pipe symbol |> and it does not require any extra packages.
%>% and |> are mostly interchangeable but behave differently within the tidy dialect than they do in base. The difference lies in how the LHE (left hand expression) is carried over.