I think you are looking for split
:
with(datain, split(LAB, ID))
# $`1`
# [1] A B C A
# Levels: A B C
#
# $`2`
# [1] B C A A
# Levels: A B C
#
# $`3`
# [1] C A A B
# Levels: A B C
#
# $`4`
# [1] A A B C
# Levels: A B C
#
# $`5`
# [1] A B C A
# Levels: A B C
Since each ID
might have a different number of LAB
s, the output is a list.
Edit: Since it now appears you only wanted unique values, do:
with(unique(datain), split(LAB, ID))
and if you don't like getting factors, do:
with(unique(datain), split(as.character(LAB), ID))