arrange rows according to a vector in r

# Create a sample data frame
data <- data.frame(ID = c(1, 2, 3, 4),
                   Name = c("Alice", "Bob", "Charlie", "David"),
                   Score = c(90, 85, 92, 88))

# Define a vector to determine the order of rows
order_vector <- c(3, 1, 4, 2)

# Use the order() function to rearrange rows based on the order vector
data <- data[order_vector, ]

# Print the resulting data frame
print(data)