Vector operations - reuse values from shorter vector



examples/vectors/reuse_short_array_exact_multiple.R
x = c(1, 2, 3, 4)
y = c(10, 20)
x+y

# There is no warning here !

examples/vectors/vector_multiplication.R
x = c(1, 2, 3, 4)
y = c(10, 20)
print(x*y)  #  10 40 30 80
# 1 * 10
# 2 * 20
# 3 * 10
# 4 * 20

examples/vectors/different_length_of_arrays.R
# R starts to reuse the shorter vector if one of the vactors is longer than the other
# gives a warning
# TODO: can we stop running at such warnings?

a = c(TRUE, TRUE, FALSE)
b = c(TRUE, FALSE, TRUE, FALSE)

a & b
a | b
! a

x = c(1, 2, 3)
y = c(10, 20)
x+y

# options(warn=2)  # turn warnings into errors
# options(warn=0)  # ???? turn warnings back to warnings