Reputation: 2545
I want to create a vector from the Fold Change column in the following melted matrix. One vector for each Pos/Pair. So 4 vectors in this example:
1) Pos 1 and Pair Yes
2) Pos 1 and Pair No
3) Pos 2 and Pair Yes
4) Pos 2 and Pair No
Pos Pair Fold Change
1 Yes -0.3617047662
1 Yes -0.6392675898
1 No 0.2679183407
1 No -0.0624585384
2 Yes -0.9540394046
2 Yes -0.4518245284
2 No -1.9135873541
2 No 0.6960538921
...
Upvotes: 1
Views: 95
Reputation: 61204
Use split
function, it'll give you a list of vectors
with(df, split(Fold_Change, list(Pos, Pair)))
# $`1.No`
# [1] 0.26791834 -0.06245854
#
# $`2.No`
# [1] -1.9135874 0.6960539
#
# $`1.Yes`
# [1] -0.3617048 -0.6392676
#
# $`2.Yes`
# [1] -0.9540394 -0.4518245
Upvotes: 1