R recycling process -
please see snippet below:
x <- c(23,43,54,75,76,6,87,5,43,234,2) y <- c(1,2,23,43,54,75,76,6,87,1) z <- x + y
the snippet gives me warning message.when try add x , y as:
#warning message: #in x + y : longer object length not multiple of shorter object length
however when add:
x <- c(3,4,5,8) y <- c(1,3) z <- x + y z
no error message thrown , r recycles perfectly. why?
first of all, important notice warning, , not error. in either case, no error thrown , vectors added.
concerning absence of warning in second example, warning message states reason quite clearly:
object length not multiple of shorter object length
in second example, length of x
twice length of y
, is multiple (in contrast first example, yields warning). hence, no warning given in second example when vector y
recycled.
Comments
Post a Comment