Introduction to R - Part 1 (COMPLETE)

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:20 PM on 7/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

45 Terms

1
New cards

FRONT

BACK

2
New cards

What functions are used to add up the elements in rows and columns of matrices? What do these function return? Provide an example of adding up a matrix’s rows.

rowSums()

colSums()

These functions return a vector with the sums

rowSums(matrix)

3
New cards

How do you check a variable’s data type?

class()

4
New cards

Can vectors store multiple vectors?

No

5
New cards

FIRST PASS

FIRST PASS

6
New cards

SECOND PASS

SECOND PASS

7
New cards

How to do exponentiation?

x ^ x

8
New cards

What is modulo and how do you do it?

Returns division remainder

x %% x

9
New cards

How do you initialize a variable with a value?

x <- number

10
New cards

How do you print a variable?

x

OR

print(x)

(OR cat(x))

11
New cards

Numerics vs Integers

Numerics: Decimal

Integers: Whole

12
New cards

True/False or TRUE/FALSE

TRUE/FALSE

13
New cards

What is a vector?

A one dimensional array

14
New cards

How do you create a vector?

c(x, y, z)

15
New cards

How do you apply labels to vector values after initialization?

names(vector) <- c(x, y, z)

16
New cards

If you add two vectors, what does this do?

c(a, b, c) + c(x, y, z) = c(a + x, b + y, c + z)

17
New cards

How to add up all the elements in a vector?

sum(x)

18
New cards

How to add up a bunch of values or numerical variables without using a plus sign?

sum(x, y, z)

19
New cards

Can you sum numeric and integer variables together?

Yes

20
New cards

How many comparison operators are in R, and what are they?

There are six comparison operators in R:

x > y

x < y

x >= y

x <= y

x == y

x != y

21
New cards

In R, is the first element of a series of elements 0, or 1?

1

22
New cards

How to obtain a single cell from a vector?

vector[x]

23
New cards

How to obtain multiple specific cells from a vector?

vector[c(x, y, z)]

24
New cards

How to obtain a range of cells from a vector?

vector[x:y]

25
New cards

How to obtain a cell from a vector using that cell’s name?

vector[“x“]

26
New cards

How to obtain multiple specific cells from a vector using those cells names?

vector[c(“x”,”y”)]

27
New cards

How to find the mean of all the elements in a vector?

mean()

28
New cards

What does it return when you use a comparison operator on a vector? Ex. vector == 5

It returns a boolean vector where a comparison is done for each element in the original vector to determine if the corresponding element in the boolean vector is TRUE or FALSE

29
New cards

What does this return?

vector[boolean vector]

A new vector that is the part of the old vector where all the boolean values were true

30
New cards

Can vectors hold elements that are different data types from one another?

No

31
New cards

What does this return? What are their data types?

1:3

1:3.9

1.3:3.9

1 2 3

1 2 3

1.3 2.3 3.3

Vector

32
New cards

How do you make a matrix?

matrix()

33
New cards

In order, what are the arguments for a matrix?

There are 5 arguments for a matrix

1st: data

2nd: nrow

3rd: ncol

4th: byrow

5th: dimnames

34
New cards

For the dimnames argument of a matrix, what can you enter?

NULL or a list. The list can be input three ways. First, it can be input as empty and will become NULL. Second, as one vector, which will become the row names. Third, as two vectors, the first of which will become the row names and the second of which will become the column names.

35
New cards

What is the byrow argument for the matrix?

byrow determines if the data is filled in by row or by columns

36
New cards

What are the ways you can enter data into a matrix?

One variable with all the data, or one variable with enough variables to fill the rows and columns

37
New cards

What functions are used to name the rows and columns of matrices after the matrix’s creation? Provide an example of naming a matrix’s rows.

rownames()

colnames()

rownames(matrix) <- row_names_vector

38
New cards

What functions are used to combine vectors and matrices by rows and columns? Provide an example of combining two matrices.

rbind()

cbind()

matrix3 <- rbind(matrix1, matrix2)

39
New cards

What is the workspace in R?

All of the currently user-defined objects

40
New cards

How do you display all of the objects in the workspace?

ls()

41
New cards

How to obtain a single cell from a matrix?

matrix[x, y]

42
New cards

How to obtain a smaller matrix from a matrix?

matrix[x:y, a:b]

43
New cards

How to obtain all the elements from a row or column of a matrix?

Whatever parameter inside of the brackets that are left blank will have everything inside selected.

Ex: matrix[1,]

44
New cards

What happens when you apply a standard operator to a matrix? Ex. matrix * 2

Applies the calculation to all elements of the matrix

45
New cards

What happens when you apply a standard operator to two matrices? Ex. matrix1 * matrix2

Takes each same cell of both matrices, and does the calculation between them