More R Flashcards

1
Q

What is the workspace

A

the collection of objects you currently have/create during the r session. it is not stored in memory unless you tell r to do so.

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

install packages vs load package

A

install.package() vs library()

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

how to read matrix

A

read.matrix()

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

how to make the first row of csv be values

A

read.csv(… header = False)

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

how to export a text file

A

write.table(mydata, name of the file, sep = “\t”)

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

is.na()

A

returns true if there is a missing value/NAN, but returns false if there is a value

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

how to recode a missing value

A

mydata[mydata$v1==99,”v1”]

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

how to exclude a missing value from analysis

A

mean(x, na.rm = TRUE)

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

must the true of false be caps

A

YES

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

how to list rows that have missing values

A

mydata[!complete.cases(mydata),] this will print the rows which

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

what does the complete cases function give

A

indicates which rows are complete, have no missing data, in the form of a logical vector. if there are 3 rows with all complete values (TRUE, TRUE, TRUE)

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

how do you select certain rows in a matrix

A

mymatrix[c(2,4),], or mymatrix[c(2:4),] if you exclude the comma, it only gives the first column

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

how to find dimensions/shape of a matrix/dataframe

A

use dim(x)

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

what does na.omit do

A

it returns a new matrix/dataframe without the missing data

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

typeof/mode vs class

A

type gives the variable inside the container, while class gives the container structure

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