Reshaping data using R or Excel
I have a data set that conatains many rows and 28 columns.
What i need is, The column with the subject ID and coc# to be unique and
the data that might be removed placed into extra columns, I might not be
explaining this very well so i will show my example
ID DOB address name date seen txdone coc#
1 1/08/1997 4blelan bob sager 19/05/2002 1125 45555
1 1/08/1997 4blelan bob sager 19/05/2002 1200 45555
1 1/08/1997 4blelan bob sager 20/06/2003 2000 46666
1 1/08/1997 4blelan bob sager 20/06/2003 1222 46666
2 5/09/1956 55lala Jim reads 19/05/2002 1125 55544
2 5/09/1956 55lala Jim reads 19/05/2002 1111 55544
2 5/09/1956 55lala Jim reads 1/06/2002 1111 55544
2 5/09/1956 55lala Jim reads 2/07/2002 1353 56678
Transformed into this
ID DOB address name dateseen1 txdone1 coc#1 dateseen2 txdone2
coc#2 date seen3 txdone3 coc#3
1 1/08/1997 4blelan bob sager 19/05/2002 1125 45555 19/05/2002
1200 45555
1 1/08/1997 4blelan bob sager 20/06/2003 2000 46666 20/06/2003
1222 46666
2 5/09/1956 55lala Jim reads 19/05/2002 1125 55544 19/05/2002
1111 55544 1/06/2002 1111 55544
2 5/09/1956 55lala Jim reads 2/07/2002 1353 56678
The reason for this is so i can search for 1125 in txdone but also get the
other work that was carried out in that COC in one line. looking at it now
i wouldnt even need multiple columns of coc just the one but you get the
idea (maybe).
I am very open to doing things differently if i am going about this
backwards. how ever i am limited to using R and excel.
No comments:
Post a Comment