R - auto-mate/CheatSheetWiki GitHub Wiki

Comment

# comment detail
OR
command # comment detail

plot

Plot simple "Emp Num" on bottom(x axis), "Clocked Hours" on y axis ( additional code added in power BI - Drag and Drop fields)

plot(dataset$"Emp Num",dataset$"Clocked Hours")  

boxplot

simple

boxplot(dataset,'Emp Num'~'Clocked Hours')

Vertical Horizontal x-axis col descriptions ["las" function]

boxplot(dataset,las=1,'Emp Num'~'Clocked Hours') 

Show Names Changed from default field names c() for columns ["names" function]

boxplot(dataset,las=1,'Emp Num'~'Clocked Hours',names=c("Employee","Tot Hours"))  

Adding an Additional Field

boxplot(dataset,las=1,'Emp Num'~'Clocked Hours'~Holiday,names=c("Employee","Tot Hours","Hol"))  

Show Data in Cols 1 3 and 4 (leave gap in 2) ["at" function)

boxplot(dataset,las=1,'Emp Num'~'Clocked Hours'~Holiday,names=c("Employee","Tot Hours","Hol"),at=c(1,3,4))  

Add Colum colours - col=colours in order of display ["col" function]

boxplot(dataset,las=2,'Clocked Hours'~Holiday,names=c("Tot Hours","Hol"),at=c(1,3),col=c("red","green"))  

Add axis titles [xlab and ylab functions]

boxplot(dataset,las=2,'Clocked Hours'~Holiday,names=c("Tot Hours","Hol"),at=c(1,3),col=c("red","green"),ylab="Hours",xlab="Ref Data")  # Add axis titles