0

Do we have something in RStudio like the SAS Enterprise Guide editor abbreviations (https://blogs.sas.com/content/sasdummy/2011/11/17/sas-program-editor-abbrevs/)?

For those who don't know, they are a "template" code snippet that can be auto-completed by typping the abbreviation/shortcut. It's really useful when some block of code is often used or when it's hard to remember the syntax.

For example, I could define the shortcut "pp" to:

ggplot(df,aes(x=x, y=y)) +
  geom_point() +
  theme(plot.title = element_text(size = 16),
        axis.text.x = element_text(angle=90, hjust=1)) +
  theme_light() +
  labs(x = "X",
       y = "Y") +
  ggtitle("TITLE")

And insert it automatically by just typing "pp" + TAB.

shs
  • 3,683
  • 1
  • 6
  • 34
lorenzi
  • 1
  • 1
  • 3
    Yes, RStudio has something called snippets that does the exact same thing. https://datacritics.com/2019/01/28/rstudio-snippets/ – Reeza Sep 13 '19 at 19:47
  • 2
    And how to use them, since that article missing that: https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets – Reeza Sep 13 '19 at 19:49
  • Not directly what you need, but you can also define a string and then evaluate it as a code [Link](https://stackoverflow.com/questions/1743698/evaluate-expression-given-as-a-string). – slava-kohut Sep 13 '19 at 19:53

0 Answers0