How to display the class of an object
Class(<object>)</object>
How to display structure of an object
Str(<object>)</object>
How to create a vector with specified quantities
c(x,y,z)
Format for creating a matrix
matrix(<data>, nrow = <n>, ncol = <m>, byrow = True)</m></n></data>
How to add new columns or rows to a matrix?
rbind(<matrix>, <vector>) & cbind(<matrix>, <vector>)</vector></matrix></vector></matrix>
How to do matrix multiplication
%*%
How to do determinant or transpose of a matrix?
det(<matrix>) or t(<matrix>)</matrix></matrix>
How to do inverse or get eigenvalues of a matrix?
solve(<matrix>) or eigen(<matrix<)</matrix>
How to load excel file into R?
Data = read.csv(“data.csv”)
How to install and load the survival package?
install.packages(“survival”), library(survival)
How to simulate a sample from a distribution?
r[dist](<n>, <params>)</params></n>
how to calculate corresponding quantile?
q[dist](<p>, <params>)</params>
What type is for the following: points, line, overplot, step graph, no plot
p , l , o , s , n
How to add titles and column labels to a graph
Titles = main(“”) , labels is xlab=“”, ylab=“”
How to add axis limits
By doing xlim and ylim for example xlim = c(0,20)
What is lty?
this is the line type , 1 is solid, 2 dashed, 3 dotted
what is lwd?
line width (default is 1, higher number is thicker)
how to add colour to a chart
using the col = function
What does pch do?
It is the shape of the plot character on a graph
what does the functions lines(<x>,<y>) do</y></x>
adds lines to existing plots
How do you add points to existing plots?
points(<x>,<y>)</y></x>
what are the different types of lines to add to a graph
We have three types of ablines: abline(<a>,<b>) plots line y = a +bx. Abline(h = <value>) plots horizontal line. Abline(v = <value>) plots vertical line</value></value></b></a>
how to add a legend to a graph
Legend(“location”, legend = c(<labels>), col= c(<colours>), lty = 1)</colours></labels>
how to add a histogram with breaks
hist(x, breaks = a:b)