May 19, 2021 at 12:00 am
Comments posted to this topic are about the item Multiplying Vectors in R
May 19, 2021 at 1:32 pm
I believe that the line j <- (4,5) is missing a 'c'. As written the answer should be Error: unexpected ',' in "j <- (4,". Good question though. Thank you Steve.
May 19, 2021 at 2:12 pm
Thanks, good catch. You are correct.
this is fixed.
May 19, 2021 at 9:32 pm
In addition to the missing 'c' on second vector, error will be thrown on matrix multiplication due to second vector being 1 element shorter than the first. Add 1 to end of second vector. Result 4 10 3.
May 19, 2021 at 10:03 pm
Not an error. A warning. This still works:
> i <- c(1,2,3)
> j <- c(4,5)
> k <- i * j
Warning message:
In i * j : longer object length is not a multiple of shorter object length
> k
[1] 4 10 12
May 19, 2021 at 11:41 pm
i <- c(1,2,3)
> j <- c(4,5)
> k <- i * j
Warning message:
In i * j : longer object length is not a multiple of shorter object length
> k
[1] 4 10 12
>
I stand corrected, my apologies.
Saw the warning: (my brain registered Error), and did not display the k value.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply