R Module 1A

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

1/52

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:31 AM on 10/6/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

53 Terms

1
New cards

echo=FALSE, eval=FALSE

Need to fill in the code chunk

2
New cards

Type of information stored in vectors

A sequence of elements of the same type

3
New cards

Common storage uses of vectors in bioinformatics

Gene expression values, sample identifiers, statistical measurements, experimental conditions

4
New cards

Key properties of vectors

All elements must be of the same type, R uses 1-based indexing (first element is at position 1), vectors can be numeric/character/logical

5
New cards

c()

Combines individual values

6
New cards

numbers <- c(1, 2, 3, 4, 5)

Creates a numeric vector called ‘numbers’ - 1, 2, 3, 4, 5

7
New cards

sequence <- 1:10

Creates a numeric vector called ‘sequence’ - numbers 1 to 10

8
New cards

repeated <- rep(5, 3)

Creates a numeric vector called ‘repeated’ - 5, 5, 5

9
New cards

seq()

Creates sequences with specific patterns

10
New cards

rep()

Repeat values

11
New cards

:

Simple integer sequences

12
New cards

<- c(2.5, 3.1, 1.8, 4.2, 2.9)

Creates a vector containing specific values - 2.5, 3.1, 1.8, 4.2, and 2.9

13
New cards

<- 1:10

Creates a vector containing the numbers from 1 to 10

14
New cards

<- seq(2, 20, by = 2)

Creates a vector containing a sequence of even numbers from 2 to 20

15
New cards

<- seq(0,24, length.out = 5)

Creates a vector containing a sequence with a specific length, 5 points from 0 to 24 - 0, 6, 12, 18, 24

16
New cards

<- rep(1, 5)

Creates a vector of 1 repeated 5 times

17
New cards

<- rep(c(“A”, “B”), each = 3)

Creates a vector with a repeated sequence, three A’s followed by three B’s

18
New cards

name <- c(“I”, “Am”, “Flo”)

Creates a character vector called ‘name’ - I, Am, Flo

19
New cards

samples <- paste("Sample", 1:5, sep = "_")

Creates a character vector called ‘samples’ - Sample_1, Sample_2, Sample_3, Sample_4, Sample_5

20
New cards

paste(x, 1:3, sep = /)

Paste joins strings together. Because R is vectorized, it takes the first element ‘x’ and attaches it to each number in the sequence. Then separates the x from the number with ‘/’ - x/1, x/2, x/3

21
New cards

length()

Displays number of elements in the vector in parentheses

22
New cards

TRUE/FALSE

Used for logical values

23
New cards

“ “

Used for character values

24
New cards

<- c(TRUE, FALSE, TRUE)

Creates a logical vector for conditions - Yes, no, yes

25
New cards

<- vector > 3.0

Creates a logical vector from comparison - new vector contains only the values in ‘vector’ higher than 3.0

26
New cards

<- vector * 2

Vector operation that doubles each element in the vector, ‘vector’ by 2

27
New cards

<- vector + numbers

Vector operation that adds the two vectors, ‘vector’ and' ‘numbers’ element-wise

28
New cards

<- log(vector)

Vector operation that takes the natural logarithm of each element in the vector, ‘vector’

29
New cards

<- vector > 2.0 & vector < 4.0

Combines logical conditions to creat a vector of all the values between 2.0 and 4.0 in the vector, ‘vector’

30
New cards

sum(vector)

Displays sum of all values of ‘vector’

31
New cards

mean(vector)

Displays average value of ‘vector’

32
New cards

median(vector)

Displays median value of ‘vector’

33
New cards

sd(vector)

Displays standard deviation of ‘vector’

34
New cards

numbers[1]

Accesses the first element of the vector, ‘numbers’

35
New cards

numbers[1:3]

Accesses the first three elements of the vector, ‘numbers’

36
New cards

numbers[c(1, 3, 5)]

Accesses specific elements of the vector, ‘numbers’ - elements 1, 3, and 5

37
New cards

numbers[length(numbers)]

Accesses the last element of the vector, ‘numbers’

38
New cards

numbers[numbers > 3]

Accesses elements greater than 3 in the vector, ‘numbers’

39
New cards

numbers[-1]

Accesses all elements except the first in the vector, ‘numbers’

40
New cards

numbers[-(4:5)]

Accesses all elements except the fourth and fifth in the vector, ‘numbers’

41
New cards

modified_vector[1] <- 5.0

Changes the first element in the vector, ‘modified_vector’ to 5.0

42
New cards

modified_vector[c(2, 4)] <- c(1.0, 1.5)

Changes the 2nd and 4th elements in the vector, ‘modified_vector’ to 1.0 and 1.5

43
New cards

numbers[numbers %% 2 == 0]

Logically indexes even numbers in the vector, ‘numbers’

44
New cards

which.max(vector)

Finds the highest value in the vector, ‘vector’

45
New cards

sample_IDs[which.max(numbers)]

Finds the position of the highest number and gets the corresponding sample name

46
New cards

sort()

Arranges values in ascending order

47
New cards

sort(x, decreasing = TRUE)

Arranges values in descending order

48
New cards

unique()

Removes duplicate values

49
New cards

which()

Finds positions of values that meet the logical condition in the parentheses

50
New cards

rev()

Reverses the order of values

51
New cards

c(vector, numbers[1:3])

Combines ‘vector’ with ‘number’ elements 1 to 3

52
New cards

<- vector[vector > 3.0]

Subsets only values over 3.0 from ‘vector’ into a new variable

53
New cards

prod(vector)

Calculates the product of all values in ‘vector’