Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

R Programming Vector Operations

31

Flashcards

0/31

Still learning
StarStarStarStar

Concatenating vectors using c()

StarStarStarStar

Joins two or more vectors end-to-end. Example: c(vec1, vec2)

StarStarStarStar

Logical OR over vector elements

StarStarStarStar

Performs element-wise logical OR. Example: vec1 | vec2

StarStarStarStar

Applying a function to each element with sapply()

StarStarStarStar

Applies a function to each element in a vector and simplifies the result if possible. Example: sapply(vec, sqrt)

StarStarStarStar

Vector modulo

StarStarStarStar

Calculates the modulus of two vectors element-wise. Example: vec1 %% vec2

StarStarStarStar

Sum of vector elements with sum()

StarStarStarStar

Calculates the sum of all elements in a vector. Example: sum(vec)

StarStarStarStar

Vector subtraction

StarStarStarStar

Subtracts two vectors element-wise. Example: vec1 - vec2

StarStarStarStar

Appending elements to a vector with append()

StarStarStarStar

Adds elements to a vector at a specified position. Example: append(vec, values=c(4, 5), after=2)

StarStarStarStar

Vector multiplication

StarStarStarStar

Multiplies two vectors element-wise. Example: vec1 * vec2

StarStarStarStar

Vector exponentiation

StarStarStarStar

Raises elements of the first vector to the powers of the second vector element-wise. Example: vec1 ^ vec2

StarStarStarStar

Using seq() to generate sequence

StarStarStarStar

Generates a sequence with specific properties. Example: seq(from=1, to=10, by=0.5)

StarStarStarStar

Vector recycling

StarStarStarStar

When applying an operation to two vectors of unequal length, the shorter one is recycled to match the length of the longer. Example: c(1, 2) + c(1, 2, 3, 4)

StarStarStarStar

Minimum value of a vector with min()

StarStarStarStar

Finds the lowest value in a vector. Example: min(vec)

StarStarStarStar

Ordering indices of vector elements with order()

StarStarStarStar

Gives the indices that would sort the vector. Example: order(vec, decreasing=TRUE)

StarStarStarStar

Ranking vector elements with rank()

StarStarStarStar

Assigns ranks to elements in a vector. Example: rank(vec)

StarStarStarStar

Vector sequence with ':' operator

StarStarStarStar

Creates a sequence of numbers. Example: 1:10 creates a vector from 1 to 10

StarStarStarStar

Sampling elements from a vector with sample()

StarStarStarStar

Randomly selects elements from a vector. Example: sample(vec, size=3)

StarStarStarStar

Mean of vector elements with mean()

StarStarStarStar

Calculates the average of all elements in a vector. Example: mean(vec)

StarStarStarStar

Logical comparison between vectors

StarStarStarStar

Compares two vectors element-wise and returns a logical vector. Example: vec1 > vec2

StarStarStarStar

Product of vector elements with prod()

StarStarStarStar

Calculates the product of all elements in a vector. Example: prod(vec)

StarStarStarStar

Median of vector elements with median()

StarStarStarStar

Finds the median value of all elements in a vector. Example: median(vec)

StarStarStarStar

Vector negation

StarStarStarStar

Switches the sign of each vector element. Example: -vec

StarStarStarStar

Vector creation using c() function

StarStarStarStar

Combines values to create a vector. Example: vec <- c(1, 2, 3)

StarStarStarStar

Vector addition

StarStarStarStar

Adds two vectors element-wise. Example: vec1 + vec2

StarStarStarStar

Logical AND over vector elements

StarStarStarStar

Performs element-wise logical AND. Example: vec1 & vec2

StarStarStarStar

Accessing vector elements with []

StarStarStarStar

Retrieves elements at specified indices. Example: vec[c(1, 3)]

StarStarStarStar

Sorting a vector with sort()

StarStarStarStar

Arranges elements in ascending or descending order. Example: sort(vec, decreasing=TRUE)

StarStarStarStar

Using all() to check if all elements are TRUE

StarStarStarStar

Checks if all elements of a logical vector are TRUE. Example: all(vec > 0)

StarStarStarStar

Vector division

StarStarStarStar

Divides two vectors element-wise. Example: vec1 / vec2

StarStarStarStar

Maximum value of a vector with max()

StarStarStarStar

Finds the highest value in a vector. Example: max(vec)

StarStarStarStar

Generating repeating sequences with rep()

StarStarStarStar

Repeats the values in a vector. Example: rep(c(1,2), times=3)

StarStarStarStar

Using any() to check if any element is TRUE

StarStarStarStar

Checks if any element of a logical vector is TRUE. Example: any(vec > 0)

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.