# Advanced R : Vector Flashcards

1
Q

What is the most important family of data types in base R…..?

A

Vectors

2
Q

Vectors comes in ……falvours or type,

A

Vectors come in two flavours: atomic vectors and lists

3
Q

There are four primary types of atomic vectors……..

A

logical, integer, double, and character (which contains strings). Collectively integer and double vectors are known as numeric vectors

4
Q

Each of the four primary types of vectors has a special syntax to create an individual value, AKA a scalar

A

string(“a”) , string(‘a’) , double = 0.1234 , integere(1234L), Logicals(TRUE (T)or FALSE(F)),

5
Q

To create longer vectors from shorter ones, use………short for combine:

A

dbl_var [1] 1 2 3 4

6
Q

how to determine type and length of vector?

A

You can determine the type of a vector with typeof() and its length with length().

7
Q

R can represent missing, or unknown values, using a special sentinel:……. (short …..). Missing values tend to be infectious: most computations involving a missing value will return another missing value.

A

NA,,,,for not applicable

8
Q

………is use to test for the presence of missingness:

A

is.na()

9
Q

When you attempt to combine different types they will be coerced in a fixed order:

A

character → double → integer → logical(CDIL). For example, combining a character and an integer yields a character:

```str(c("a", 1))
#>  chr [1:2] "a" "1"```
10
Q

how can we coarce delibaterly?

A

Generally, you can deliberately coerce by using an as.*() function, like as.character(), as.double(), as.integer(), or as.logical(). Failed coercion of strings generates a warning and a missing value:

11
Q

setting and geeting attribut

A

You can think of attributes as name-value pairs16 that attach metadata to an object. Individual attributes can be retrieved and modified with attr(), or retrieved en masse with attributes(), and set en masse with structure().

There are only two attributes that are routinely preserved:

names, a character vector giving each element a name.
dim, short for dimensions, an integer vector, used to turn vectors into matrices or arrays.

12
Q

These are 3 ways of ……. vector
# When creating it:
x

A

naming a vector