I faced a problem that R does't see the argument I specify in ggplot function. Here is the code I use:
s_plot <- function(data, aaa, bbb,){
ggplot(data, aes(x = aaa, y = bbb))+geom_point(size=2, shape=8, col="red")
}
As a result I got an error:
object aaa not found
What's the problem? How to resolve it?
Thanks a lot.
UPD:
Sorry, but I provide you with the simplest example and it doesn't translate the whole problem. Here is the full code I use:
s_plot <- function(data, n_after, perc_cap, n_xlab, n_ylab, x_min){
ggplot(data, aes(x={{n_after}}, y={{perc_cap}})) + geom_point(size=2, shape=8, col="red")+
xlab(n_xlab)+ ylab(n_ylab)+xlim(x_min, 1.1*max(data$n_after))+ ylim(0, 1.1*max(data$perc_cap))+
geom_text(aes(x=n_after, y=perc_cap, label = NAME), hjust=0, vjust=-1.5)+
geom_vline(xintercept=8, col = "darkgreen",lty=2, size=1)+
geom_text(aes(x=8, label=label, y=20), colour="steelblue", angle=90, hjust=-1)+
theme(axis.title.y = element_text(size=15),
axis.title.x = element_text(size=15))
As you may see n_after
and perc_cap
are mentioned in several places. And this probably is the source of problem. How to resolve it in this particular case?