R tip-of-the-day
So many awesome ways to do R. I’ll share some, you’ll share some, it will be fun.
number | tip | description | misc |
---|---|---|---|
Tip 1 |
cmd + opt + i |
adds a new R chunk |
cntrl + alt + i for PC |
Tip 2 |
adds a new R chunk |
look for it at top of Quarto doc |
|
Tip 3 |
Tools -> Global Options… -> Appearance |
allows for dark mode, plus other options! |
|
Tip 4 |
cmd + shift + C |
comments the line |
cntrl + shift + C for PC |
Tip 5 |
|
LaTeX formatting to change the text color |
when render to pdf (different syntax for render to html) |
Tip 6 |
changes the figure size |
gear in R chunk |
|
Tip 7 |
changes the viewer output |
gear near Render |
|
Tip 8 |
|
evaluates the chunk, but does not show the code |
alternatively: |
Tip 9 |
Tools -> Global Options… -> Spelling |
allows for real-time spell check |
|
Tip 10 |
cmd + shift + M |
produces a pipe |
cntrl + shift + M for PC |
Tip 11 |
opt + - |
produces the assignment operator, |
|
Tip 12 |
R was adopted as an open source version of S |
It was written by Ross Ihaka and Robert Gentleman, which is why they called it R |
|
Tip 13 |
highlight with mouse and hit quotation |
will put quotes around the highlighted phrase |
|
Tip 14 |
highlight with mouse and hit parenthesis |
will put parentheses around the highlighted phrase |
|
Tip 15 |
Session -> Restart R |
rerstart the R session (without restarting RStudio) |
shift + cmd / cntrl + 0 |
Tip 16 |
cmd + d |
deletes the line |
cntrl + d for PC (works on code or narrative) |
Tip 17 |
Tools -> Keyboard Shortcuts Help |
provides all the keyboard shortcuts |
opt + shift + K on Mac; alt + shift + K on PC |
Tip 18 |
$ LaTeX code $ |
formats LaTeX code into math |
cool way to write mathematical notation |
Tip 19 |
cmd + click on a function name |
shows the inside of the function |
cntrl + click on a function name for PC |
Tip 20 |
cmd + shift + P |
shows the keyboard shortcuts for the pull-down menus |
cntrl + shift + P on PC |
Tip 21 |
cmd + shift + D |
duplicate the line |
cntrl + shift + D |
Tip 22 |
cmd + shift + up (or down) arrow |
highlights lines |
cntrl + shift + up (or down) arrow on PC |
Tip 23 |
cmd + opt + c |
runs the chunk |
cntrl + opt + c on PC |
Tip 24 |
cmd + shift + A |
reformats whatever is highlighted |
cntrl + shift + A on PC |
Tip 25 |
cntrl + l |
clears the console |
|
Tip 26 |
cmd + opt + o |
collapse R chunks |
cmd + opt + O to open them back up |
Tip 27 |
View(dataframe) |
opens the dataframe as a new tab |
don’t use in .qmd file |
Tip 28 |
Tools -> Global Options… -> Code -> Display -> Use rainbow parentheses |
colors parentheses for easier matching |
|
Tip 29 |
?function_name |
Opens up the help file on that function |
|
Tip 30 |
Only use install.packages() in the console |
don’t use it in the .qmd file |
|
Tip 31 |
cmd + opt + r |
runs the entire file |
cntrl + opt + r on PC |
Tip 32 |
DT::datatable() function |
creates searchable tables |