I am looking to find a way to create a new column "signup". This column takes the value of column 2 where column 1 == "c". And that must be done for each user_id.
user_id 1 2 count
1 a 21/01/2016 2
1 a 1/02/2016 2
1 b 1/12/2015 6
1 b 14/12/2015 6
1 b 1/12/2015 6
1 b 1/12/2015 6
1 b 14/12/2015 6
1 b 1/12/2015 6
1 c 10/12/2015 1
Result would be something like that:
user_id 1 2 count signup
1 a 21/01/2016 2 10/12/2015
1 a 1/02/2016 2 10/12/2015
1 b 1/12/2015 6 10/12/2015
1 b 14/12/2015 6 10/12/2015
1 b 1/12/2015 6 10/12/2015
1 b 1/12/2015 6 10/12/2015
1 b 14/12/2015 6 10/12/2015
1 b 1/12/2015 6 10/12/2015
1 c 10/12/2015 1 **10/12/2015**
NOTE: For each user_id, there is only one row such that column 2 is equal to "c".
I am currently learning data.table so I have preference for a solution that uses that package. Any solution, however, is appreciated.