city1_temps and city2_temps with exact valuesn that stores the length of the vectorscity1_temps and city2_temps with exact valuesn that stores the length of the vectorscity1_temps with values c(20, 22, 19, 24, 21) and another numeric vector called city2_temps with values c(18, 21, 20, 23, 22).Use the c() function to create vectors with the exact numbers given.
n that stores the length of the vector city1_temps using the length() function.Use length(city1_temps) to find how many elements are in the vector.
sum_temps as the element-wise sum of city1_temps and city2_temps, diff_temps as the element-wise difference, prod_temps as the element-wise product, and quot_temps as the element-wise quotient.Use +, -, *, and / operators directly on the vectors for element-wise operations.
sum_temps, diff_temps, prod_temps, and quot_temps each on a separate line using the print() function.Use print() for each vector to see the results on separate lines.
What happens when you add two vectors of the same length in R, like c(1, 2, 3) + c(4, 5, 6)?
c(1, 2, 3) and c(4, 5, 6) results in c(1+4, 2+5, 3+6) which is c(5, 7, 9).Which of the following is the correct syntax to subtract two vectors a and b element-wise in R?
- directly between vectors.a - b is valid R syntax for element-wise subtraction. The other options are not built-in R functions or operators.- operator for vector subtraction [OK]What is the output of the following R code?
v1 <- c(2, 4, 6)
v2 <- c(1, 3, 5)
result <- v1 * v2
print(result)
c(2, 12, 30).Consider this R code snippet:
v1 <- c(1, 2, 3)
v2 <- c(4, 5)
result <- v1 + v2
print(result)
v1 has length 3, v2 has length 2. They differ in length.You have two vectors representing daily sales for two stores:store1 <- c(10, 20, 30, 40)store2 <- c(5, 15, 25, 35)
How do you calculate the total sales per day for both stores combined using vector arithmetic?
store1 and store2 element-wise sums daily sales: c(10+5, 20+15, 30+25, 40+35) = c(15, 35, 55, 75).Pass the test and this pattern moves unknown