Programming with R Part 2 Flashcards

1
Q

How do you simulate data with R?

A

rnorm

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

Why is setting the seed important?

A

So that you have the same randomness every time (repeatability)

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

Why is it important to sample?

A

In the event that you have a large dataset, you can just work on a sample to test your algorithms

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

How do you set matrices?

A

matrix(c(vector), nrow, ncol)

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

if you want to do algebra, what symbol do you need in order to signify that?

A

%

for example, %*% will allow you to multiply

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

How do you run a function?

A

apply(m, dimcode, function, functionArgs)

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

What is a list?

A

A vector that can contain elements of different modes/classes/data types

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

What are factors

A

Factors represent nominal/categorical data

> x x
[1] yes yes no yes no
Levels: no yes

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

What are data frames?

A

Stores tabular data

Basically a 2D list (a list of lists)

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