I have the following matrix:
I want to create 2 new matrix for the companies! with the company code as distribution key.
I have the following matrix:
I want to create 2 new matrix for the companies! with the company code as distribution key.
Like @MrFlick said, no pictures of data; rather use a minimal example like this:
df <- data.frame(Company = c(1, 1, 1, 2, 2, 2), v1 = c(1, 2, 3, 1, 2, 2), v2 = c(2, 2, 4, 2, 2, 1), v3 = c(1, 1, 1, 3, 1, 1))
To come back to your problem, subset
is perfectly suited for this:
comp1 <- subset(df, Company == 1)
comp2 <- subset(df, Company == 2)