I would like a little help with this code. So I basically need to create a function where I sum three vectors until the length of the shortest one. My problem is the following:
Whenever the sum is made with v4(NULL) the function returns me NULL instead of "numeric(0)" and when I sum v2,v3 and v5 the function also returns me NULL (which is strange since these three vectors contain values).
I am happy to help you if you can make it clear what output you're expecting to get.
In short, NULL will differ from case to case depending on what code you use and how it needs to work. To have v4 as a scalar or single length vector is already not great. Similarly, it is not the same as 0 so to speak. Also, functions don't use it in the same way:
Also, having different lengths, such as v2 being a length of 8 vs 10 vs the others will also have other implications. The best is to simplify the problem into its components and then to address each one separately.