I have a current R data.table that looks like this (toy example)
ID Call Sample
ID1 AA S1
ID2 AB S1
ID3 AA S1
ID1 AB S2
ID2 AB S2
ID3 AA S2
I'd like to create a new table from this one that (1) Groups by Sample, (2) Rearranges the table structure. Here's what I want the output to look like
Sample ID1 ID2 ID3
S1 AA AB AA
S2 AB AB AA
I'm familiar with the super basics of dplyr and data.table, but can't seem to quite figure this out. If possible, I'd like to use these along with base R functions to do this transformation. However, I'm also willing to branch out to other packages if this can't be done with these.