Compute the Correlation Coefficient Value between Two Vectors in R Programming - cor() Function Last Updated : 15 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report cor() function in R Language is used to measure the correlation coefficient value between two vectors. Syntax: cor(x, y, method) Parameters: x, y: Data vectors method: Type of method to be used Example 1: Python3 1== # Data vectors x <- c(1, 3, 5, 10) y <- c(2, 4, 6, 20) # Print covariance using Pearson method print(cor(x, y, method = "pearson")) Output: [1] 0.9724702 Example 2: Python3 1== # Data vectors x <- c(1, 3, 5, 10) y <- c(2, 4, 6, 20) # Print covariance using Pearson method print(cor(x, y, method = "kendall")) Output: [1] 1 Example 3: Python3 1== # Data vectors x <- c(1, 3, 5, 10) y <- c(2, 4, 6, 20) # Print covariance using Pearson method print(cor(x, y, method = "spearman")) Output: [1] 1 Comment More infoAdvertise with us Next Article How to Extract Correlation Coefficient Value from Correlation Test in R N nidhi_biet Follow Improve Article Tags : R Language R Math-Function R Vector-Function Similar Reads Compute the Covariance between Two Vectors in R Programming - cov() Function cov() function in R Language is used to measure the covariance between two vectors. Syntax: cov(x, y, method) Parameters: x, y: Data vectors method: Type of method to be used Example 1: Python3 1== # Data vectors x <- c(1, 3, 5, 10) y <- c(2, 4, 6, 20) # Print covariance using Pearson method p 1 min read How to Extract Correlation Coefficient Value from Correlation Test in R In R Language you can compute the correlation between two variables using functions like cor() or cor.test(). The cor() the function gives the correlation coefficient directly, while the cor.test() function provides a more comprehensive output, including the correlation coefficient, p-value, confide 3 min read Calculate cosine of a value in R Programming - cos() Function cos() function in R Language is used to calculate the cosine value of the numeric value passed to it as argument. Syntax: cos(x) Parameter: x: Numeric value Example 1: Python3 1== # R code to calculate cosine of a value # Assigning values to variables x1 <- 90 x2 <- 30 # Using cos() Function c 1 min read How to Find P-Value for Correlation Coefficient in R Correlation is a statistical technique used to determine the strength and direction of the linear relationship between two variables. The correlation coefficient (denoted as r) quantifies this relationship, but understanding whether this correlation is statistically significant is just as important. 3 min read Add Correlation Coefficients with P-values to a Scatter Plot in R In this article, we will discuss how to add correlation coefficients with P-value to a scatter plot in the R Programming Language. To add correlation coefficient with P-value to a scatter plot, we use the stat_cor() function of the ggpubr package in the R Language. The ggpubr package provides some e 2 min read Compute the cosine value which is multiples of pi in R Programming - cospi() Function cospi() function in R Language is used to compute the cosine value of x which is the multiples of pi. Syntax: cospi(x) Parameters: x: Numeric value, array or vector Example 1: Python3 # R program to illustrate # cospi function # Calling the cospi() function cospi(0) cospi(1) Output: [1] 1 [1] -1 Exa 1 min read Like