R Basics Cheat Sheet



vi is one of the most commonly used editor program and included by default with every UNIX and linux system. vi basically operates in 3 modes, namely :

R Basics Cheat Sheet Pdf

  1. vi mode – the mode vi starts in
  2. command mode – you can be in command mode from the vi mode by pressing the key colon (“:”)
  3. input mode – in this mode user starts the actual editing of the text

Below are some of the most commonly used vi commands in all 3 modes of operation.

Basics

vi mode commands

CommandAction
kMove one line upwards
lMove one character to the right
hMove one character to the left
wMove one word to the right
WMove one word to the right past punctuation
bMove one word to the left
BMove one word to the left past punctuation
eMove to the end of the current word
1GMove to the beginning of the file
HMove to the top of the current screen
MMove to the middle of the current screen
LMove to the bottom of the current screen
Ctrl-GMove to the last line in the file
Ctrl-FMove one screen towards the end of the file
Ctrl-DMove 1/2 screen towards the end of the file
Ctrl-BMove one screen towards the beginning of the file
Ctrl-UMove 1/2 screen towards the beginning of the file
Ctrl-LRefresh the screen
5GMove to line 5 of the file (5 can be any line number)
/stringFind text string forward
?stringFind text string backward
nFind forward next string instance after a string search
NFind backward next string instance after a string search
ZZSave the file exit vi
xDelete the character at the cursor
XDelete the character behind the cursor
ddDelete the line the cursor is on
10ddDelete the 10 lines following the cursor
yyYank the current line
pPut the yanked line below the current line
PPut the yanked line above the current line

GIT CHEAT SHEET STAGE & SNAPSHOT Working with snapshots and the Git staging area git status show modified files in working directory, staged for your next commit git add file add a file as it looks now to your next commit (stage) git reset file unstage a file while retaining the changes in working directory git diff. The devtools package makes it easy to build your own R packages, and packages make it easy to share your R code. Supplement this cheat sheet with r-pkgs.had.co.nz, Hadley’s book on package development. Rnorm(n,mean,sd) #randomly generate n numbers from a Normal distribution with the specific mean and sd pnorm #find probability (area under curve) of a Normal(10,3^2) distribution to the left #of 8,i.e.

Command mode commands

R Basics Cheat Sheet

R basics cheat sheet excel
CommandAction
:g/X/s//x/gGlobal Search and replace (X=search object x=replace object)
:r fileImport a file into the current file
:34 r fileImport a file into the current file after line 34
:wWrite out the file to save changes
:w fileWrite the file to named file
:wqSave the file exit vi
:w!Force save the file
:q!Quit vi but don’t save changes

Input mode commands

Basics
CommandAction
aInsert characters to the right of the cursor
AAppend characters to the current line
iInsert characters to the left of cursor
IInsert characters at the beginning of the current line
oAdd a new line after current line
OInsert a new line above the current line