Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

Using R trying to merge raw matrix to result a matrix based on the value of the row value.

Ex:

from:

1  2

a1 10

a1 20

a1 40

a2 45

a2 50

a3 40

a4 45

a4 60

to:

10 20 40

45 50

40

45 60

1 Answer

0 votes
by (41.4k points)

To create a list of vectors, use split:

split(df1[,2], df1[,1])

#$a1

#[1] 10 20 40

#$a2

#[1] 45 50

#$a3

#[1] 40

#$a4

#[1] 45 60

Browse Categories

...