Rstudio 1 Flashcards

1
Q

how to code an object called bob and make it represent 5

A

bob=5

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

how to code an object called bob and make it represent hello

A

bob=”hello”

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

what is an alternative to =

A

<-

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

how to calculate an equation with objects

A

bob + bob = 10

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

vector and how to make one called vector1

A

store of numbers/names in order, 1D, vector1= c(1, 2, 3, 4, 5) or vector1= c(1:5)

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

how to multiply a vectors values to change vector

A

vector1 * 5

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

to get mean/median/min/max of vector1

A

mean(vector1) etc

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

to get mean/median/min/max of a category in vector1

A

mean(vector1$category) etc

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

standard deviation

A

how much the data spreads from the average, sd(vector1)

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

sample size

A

counts the amount of data, in a vector, length(vector1)

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

dataframe

A

2D, several vectors form a dataframe

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

to repeat a vector two times (for example)

A

name the repeating command, rep1 = rep(vector1, 2) so there will be 10 samples not 5

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

how to get random numbers

A

make new vector, vector2 = rnorm(10, mean = 5, sd = 2), 10 sample size

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

merge vectors together

A

change first vector to data frame, first name dataframe (mydata), mydata= as.data.frame(vector1, stringsAsFactors = T), then add another vector by mydata$category1 = vector1

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

to get overview of dataframe/vector

A

summary(mydata$category1) or str(mydata$category1)

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