Entering edit mode
5.2 years ago
Asia Alterego
▴
10
Is there an open thread about calculations in RStudio? If not, here is my very simple question. Consider:
vector_a <- (-5:5)
and
vector_b <- (0:10)
I have to calculate the difference/sum/product between values in vector_a and values in vector_b.
Sum <- sum(vector_a, vector_b)
returns value 55.
But product and difference functions return strange results.
If I use the command:
Difference <- vector_a - vector_b
this returns values 1, 1, 1, 1,1,..
When I use the command:
Difference <- diff(vector_a, vector_b)
returns error!
Does anybody can explain what are the right commands for these basic calculations?, Thanks for your help.