Lab2 - R Data Types and Data Structures Flashcards

(54 cards)

1
Q

What does dynamically typed mean in R?

A

Types inferred when values are created

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

Which type represents strings?

A

Character

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

Which type represents whole numbers?

A

Integer (L suffix)

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

Which type represents decimal numbers?

A

Numeric

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

Which type holds complex numbers?

A

Numeric with imaginary component

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

Which type holds boolean values?

A
  1. Logical (TRUE/FALSE)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which function checks numeric type?

A

is.numeric()

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

Which function coerces to integer?

A

as.integer()

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

Which functions round numbers? ( 3 )

A

round(), ceiling(), floor()

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

Which functions compute basic statistics? ( 5 )

A

sum(), mean(), sd(), min(), max()

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

Which function summarizes data frames?

A

summary()

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

Which functions create sequences and repetitions?

A

seq(), rep()

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

Which function checks character type?

A

is.character()

as.character()

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

List out function for string concatenation

A
  1. paste()
  2. paste0()
  3. sprintf()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which function counts characters?

A
  1. nchar()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which functions extract substrings? ( 2 )

A
  1. substr()
  2. substring()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which functions change case?

A
  1. tolower()
  2. toupper()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which functions match patterns?

A
  1. grep()
  2. grepl()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which function splits strings?

A
  1. strsplit()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which function checks logical type?

A
  1. is.logical()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Which function coerces to logical?

A
  1. as.logical()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Which functions test logic across vectors? ( 2 )

23
Q

Which function returns TRUE indices?

Returns the index of the first occurrence of TRUE or the maximum number if a numeric vector is provided

24
Q

Which function returns index of first max?

25
Which function shows low-level type?
1. typeof()
26
Which function shows high-level type?
1. class()
27
What is an R vector?
One-dimensional, same-type elements
28
How to create a vector?
Use c() annotation ``` c(TRUE, FALSE, T, F, F) ```
29
How to subset a vector?
Use [ ] with 1-based indices
30
What is an R list?
One-dimensional, mixed-type elements ``` list(c("Male", "Female", "Female", "Male", "Female")) ```
31
What is the starting index in R?
1. 1 ## Footnote Not 0
32
How to subset list elements?
Use [ ], [[ ]], or $
33
What is an R matrix?
Two-dimensional, single-type elements ``` matrix(1:6, nrow=2, ncol=3) ```
34
How to create a matrix?
1. Use matrix()
35
How to subset a matrix?
Use [row, col]
36
What is an R array?
Multi-dimensional, single-type elements"
37
How to create an array?
Use array()
38
How to subset an array?
Use [i, j, k] with indices i = row j = col z = matrix layer
39
Which function gets object names?
1. names()
40
Which function returns object length?
1. length()
41
Which functions get dimensions? ( 3 )
1. dim() 2. nrow() 3. ncol()
42
Which function flattens a list?
unlist()
43
Which functions combine by rows/columns?
1. rbind() 2. cbind()
44
Which operator checks membership?
"%in%
45
Which function samples values?
1. sample()
46
What is a factor?
Efficient representation of categorical data
47
What are factor levels?
Unique categories stored as labels
48
What are integer codes in factors?
Numeric mapping to levels
49
How to access factor levels?
1. Use levels()
50
How to access factor labels?
Use labels()
51
What is the default structure for tabular data in R?
1. Data Frame ( data.frame )
52
Why use data.table?
1. Higher Performance, Optimised for speed and memory efficiency 2. Supports in-place modification 3. Used where high-speed processing is required
53
Why use Tibbles rather than data frame?
1. Modern and more user friendly alternative to data.frame 2. Displays tidier and cleaner data previews 3. Used in Tidyverse workflows
54
Name key R structures for analysis.
1. Vectors 2. Factors 3. Data frames 4. Tibbles 5. Lists 6. Matrices