How to use simulated data

Hello, i am fairly new to RStudio, so please excuse me if this question is rather basic. Im used to having named variables from a data set and dont use self simulated data much.

i generated a data set with

x = mvrnorm(n, mu, Sigma)
with 2 Variables in a correlation matrix for Sigma.

I now need to use only one of the simulated variables and i have no idea how to extract variable 1 or 2 separately.

Thank you very much!

Hello, welcome to the forum , I see its your first time posting. First advice for you is to declare the package your function is from. mvrnorm is a function in several CRAN packages. I would guess MASS is the most likely?

the result of this is a matrix with 2 columns and many rows ?
therefore to get var1 and var2 columns out you can use

var1 <- x[,1]
var2 <- x[,2]

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

thank you, yes I used it with the MASS package

Thanks alot! I knew it was probably simple but couldnt find it anywhere else.