5-7 Flashcards

1
Q

function to find out where NAs are located in data.

A

is.na()

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

Which numbers R is representing for True and False?

A

R represents TRUE as the number 1 and FALSE as the number 0

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

How to find out how many na in dataset?

What kind of answer does the function yields

A

sum(is.na(…))

True/False

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

What do NA and NaN stand for?

A

not available and not a number

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

Get the first 10 elements of a vector called x

A

x[1:10]

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

Which sign gives us the negation of a logical expression

A

!

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

if we want to create a vector called y that contains all of the non-NA| values from x(the dataset)

A

y

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

y is a vector. What does y > 0 yields

A

a vector of logical values the same length as y, with TRUEs corresponding to values of y that are greater than zero and FALSEs corresponding to values of y that are less than or equal to zero.

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

What do […] do

A

you want to select some particular elements (i.e. a ‘subset’) from a vector by placing an ‘index vector’ in square brackets

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

subset the 3rd, 5th, and 7th elements of x

A

x[c(3,5,7)]

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

if we’re interested in all elements of x EXCEPT the 2nd and 10th?

A

x[c(-2, -10)] or better: x[-c(2, 10)]

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

main difference between matrices and dataframes?

A

matrices can only contain a single class of data, while data frames can consist of many different classes of data

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

Can you create a sequence without c()?

A

you don’t need the c() function when using :

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

Find out length of a vector

A

length() function

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

What does dim() function do? Give an example for every use.

A

dim() function allows you to get OR set the dim attribute for an R object.

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

row or column first in general?

A

row

17
Q

You want to create a matrix, but don´t know how. What to do?

A

?matrix

18
Q

You want to bind a character vector with names to a matrix with data

A

data.frame(patients, my_matrix). If you use cbind() you get a matrix with all being character vectors, because matrices can only take one type of data.

19
Q

you have a character string with column names, cnames, and a dataframe, my_data. You want to get the column names above the data frame. What to do?

A

colnames(my_data)