数组长度

数组和集合 / 数组

numbers <- c(1, 2, 3)
length_numbers <- length(numbers)
# length_numbers = 3

# Count by condition
count_odd <- sum(numbers %% 2 == 1)
# count_odd = 2

is_empty <- length_numbers == 0
# is_empty = FALSE

cat("length_numbers =", length_numbers, "\n")
cat("count_odd =", count_odd, "\n")
cat("is_empty =", is_empty, "\n")