Hello,

I am new to Rstudio and having trouble to make a correlation between 5 columns of data?

Can anyone help?

Thanks

Hello,

I am new to Rstudio and having trouble to make a correlation between 5 columns of data?

Can anyone help?

Thanks

You will need to provide more information, preferably a reprex, to provide any help.

In general, if you want to get a correlation matrix, it is really simple using the cor function.

```
# setting seed
set.seed(seed = 23493)
# generating random data
x1 <- runif(n = 100)
x2 <- rnorm(n = 100)
x3 <- rcauchy(n = 100)
x4 <- rexp(n = 100)
x5 <- rlogis(n = 100)
# combining to get a dataset of 5 columns
d <- data.frame(x1,
x2,
x3,
x4,
x5)
# finding correlation matrix
(r <- cor(x = d))
#> x1 x2 x3 x4 x5
#> x1 1.000000000 0.005969777 0.04610351 0.080191762 -0.090464853
#> x2 0.005969777 1.000000000 0.14000817 -0.027236185 -0.094456667
#> x3 0.046103509 0.140008173 1.00000000 0.056563325 -0.080159816
#> x4 0.080191762 -0.027236185 0.05656333 1.000000000 -0.008438071
#> x5 -0.090464853 -0.094456667 -0.08015982 -0.008438071 1.000000000
```

^{Created on 2019-02-10 by the reprex package (v0.2.1)}

In addition to what @Yarnabrina wrote, I would like to add that it might be useful for you to understand the difference between RStudio and R, which is the programming language and execution environment that is run under the hood of RStudio when you create and execute a script in RStudio.

RStudio is a (quite powerful) integrated development environment for R but other exist. In other words, the cor function mentioned by @Yarnabrina is an R function that can be run in RStudio but is intrinsically not a RStudio function. You could run the same code and function outside of RStudio. Reading the some sections of the Introduction to R could help.