RStudio Flashcards

(30 cards)

1
Q

How to display the class of an object

A

Class(<object>)</object>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to display structure of an object

A

Str(<object>)</object>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to create a vector with specified quantities

A

c(x,y,z)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Format for creating a matrix

A

matrix(<data>, nrow = <n>, ncol = <m>, byrow = True)</m></n></data>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to add new columns or rows to a matrix?

A

rbind(<matrix>, <vector>) & cbind(<matrix>, <vector>)</vector></matrix></vector></matrix>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to do matrix multiplication

A

%*%

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to do determinant or transpose of a matrix?

A

det(<matrix>) or t(<matrix>)</matrix></matrix>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to do inverse or get eigenvalues of a matrix?

A

solve(<matrix>) or eigen(<matrix<)</matrix>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to load excel file into R?

A

Data = read.csv(“data.csv”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to install and load the survival package?

A

install.packages(“survival”), library(survival)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to simulate a sample from a distribution?

A

r[dist](<n>, <params>)</params></n>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how to calculate corresponding quantile?

A

q[dist](<p>, <params>)</params>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What type is for the following: points, line, overplot, step graph, no plot

A

p , l , o , s , n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to add titles and column labels to a graph

A

Titles = main(“”) , labels is xlab=“”, ylab=“”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to add axis limits

A

By doing xlim and ylim for example xlim = c(0,20)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is lty?

A

this is the line type , 1 is solid, 2 dashed, 3 dotted

17
Q

what is lwd?

A

line width (default is 1, higher number is thicker)

18
Q

how to add colour to a chart

A

using the col = function

19
Q

What does pch do?

A

It is the shape of the plot character on a graph

20
Q

what does the functions lines(<x>,<y>) do</y></x>

A

adds lines to existing plots

21
Q

How do you add points to existing plots?

A

points(<x>,<y>)</y></x>

22
Q

what are the different types of lines to add to a graph

A

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>

23
Q

how to add a legend to a graph

A

Legend(“location”, legend = c(<labels>), col= c(<colours>), lty = 1)</colours></labels>

24
Q

how to add a histogram with breaks

A

hist(x, breaks = a:b)

25
How to plot a density histogram
Hist(x, probability = TRUE)
26
how to plot quantiles of a Sample against a normal dist
Qqnorm()
27
How to add a comparison line to a qq plot
Qqline()
28
How to plot quantiles of a sample against Theoretical quantiles from a dist?
Qqplot(, )
29
how to fit a linear model of form y = a + bx
Lm(~)h
30