Write an R program to find the correlation between two numeric vectors.
EasyProblem Statement
Write an R program to find the correlation between two numeric vectors.
Sample Input
Vector 1: c(1, 2, 3, 4, 5) Vector 2: c(2, 4, 6, 8, 10)
Sample Output
Correlation: 1
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
# Predefined structure
vector1 <- c(1, 2, 3, 4, 5)
vector2 <- c(2, 4, 6, 8, 10)
correlation <- cor(vector1, vector2)
print(paste("Correlation:", correlation))
Input
Vector 1: c(1, 2, 3, 4, 5) Vector 2: c(2, 4, 6, 8, 10)
Expected Output
Correlation: 1