R / Positron tip-of-the-day

So many awesome ways to do R in Positron. I’ll share some, you’ll share some, it will be fun.

number tip description misc
Tip 1 cmd + shift + P Command Palette - does everything cntrl + shift + P for Windows
Tip 2 color = “#4CBB17” (kelly green!) in ggplot2 use any color
Tip 3 geom_bar() vs geom_col() no y variable in geom_bar() geom_bar() does the counting for you
Tip 4 position = "dodge" use to show information that overlaps available in many geom_*() functions
Tip 5 keyboard up arrow brings back the previous line works in Console or Terminal
Tip 6 highlight code + cmd + enter will run only the highlighted code highlight code + cntrl + enter on Windows
Tip 7 scales = "free" inside facet_grid() or facet_wrap() for allowing variable axes also options of "free_x" or "free_y"
Tip 8 + labs(shape = "The Species", color = "The Species") change the label in ggplot for two aspects for the same label
Tip 9 + scale_shape_manual(values = c("IL" = 16, "IN" = 17, "MI" = 15, "OH" = 18, "WI" = 7)) manually change the plotting symbol alternatively: scale_shape_manual(values = c(16, 17, 15, 18, 7))
Tip 10 + labs(title = "Here is a super long title\n that I want on two lines.") \n to linebreak the title
Tip 11 cmd + shift + m shortcut for the pipe, |> cntrl + shift + m on Windows
Tip 12 opt + dash shortcut for the assignment, <- alt + dash on Windows
Tip 13 count() counts items in groups not used inside a tidy verb e.g., penguins |> count(island)
Tip 14 need & with filter if you use | comma is a shortcut for and, unless you also have or
Tip 15 cntrl + L clears the console e.g., if you do not like looking at the error messages
Tip 16 unique() gives the unique values in a variable, cannot be used in a tidy pipeline instead: `penguins |> distinct(species)
Tip 17 highlight code + cmd + shift + c comments lines to not render cntl + shift + c on Windows
Tip 18 alpha = 0.4 makes the plot item (e.g., point) transparent, e.g., 40% of the ink can be used in geom_point(), geom_text(), and other geoms
Tip 19 highlight code + cmd + [ (or highlight code + cmd + [) shifts the code left (or right) highlight code + cntrl + [ on Windows

Reuse

CC-BY-SA-4.0