row.names(USArrests)[1:10] [1] "Alabama" "Alaska" "Arizona" "Arkansas" "California"
[6] "Colorado" "Connecticut" "Delaware" "Florida" "Georgia"
A full list of keyboard shortcuts available in RStudio can be found here.
Quarto keyboard shortcuts can be found here.
| Description | Windows & Linux | Mac |
|---|---|---|
| Run current line/selection | Ctrl+Enter | Cmd+Return |
| Run from document beginning to current line | Ctrl+Alt+B | Cmd+Option+B |
| Add Cursor Above Current Cursor | Ctrl+Alt+Up | Ctrl+Option+Up |
| Add Cursor Below Current Cursor | Ctrl+Alt+Down | Ctrl+Option+Down |
| Comment/uncomment current line/selection | Ctrl+Shift+C | Cmd+Shift+C |
| Insert code section | Ctrl+Shift+R | Cmd+Shift+R |
| Insert pipe operator | Ctrl+Shift+M | Cmd+Shift+M |
| Find and Replace | Ctrl+F | Cmd+F |
| Save active document | Ctrl+S | Cmd+S |
| Restart R Session | Ctrl+Shift+F10 | Cmd+Shift+F10 |
The dput() function gives you the code to generate an R object instead of just displaying the output values. Lets say we have a list of US state names we want to use in some code for another task. If we print it, R will show us the output values:
row.names(USArrests)[1:10] [1] "Alabama" "Alaska" "Arizona" "Arkansas" "California"
[6] "Colorado" "Connecticut" "Delaware" "Florida" "Georgia"
With dput(), we can get the full code to recreate the vector:
row.names(USArrests)[1:10] |>
dput()c("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado",
"Connecticut", "Delaware", "Florida", "Georgia")