Reshaping Data in R

r
data_mining
data_science
rcode

#1

I have a data in following Format on R

ID Product
A p1
B p1
B p2
C p1
C p2
C p3

and i want to output to shown like

ID
A p1
B p1 p2
C p1 p2 p3

HOw can i do that in R ?
or can we do that using Reshape package in R?


#2

You can use library-‘tidyr’ and command is
df1<- spread(df,Product)