How do I put data with multiple possible values in Tidy format? Say I had data that had a user_id, date, and problem code recorded each time that a user makes a call. And I want to answer questions like "how many calls did the user make?" and "what problem codes were reported most frequently?"
I think I'm 90% there with something like the following:
ID, date, problem-code
A44, 2016-12-09, P809
A44, 2016-12-09, P810
...
A99, 2016-12-09, P809
A99, 2016-12-09, P810

Where each row is a phonecall record. However, let's say that first one, user A44 actually called in ONCE, and two problem codes were reported, while A99 called in twice with a single problem code each time. Something like this feels wrong:
ID, date, problem-code
A44, 2016-12-09, [P809, P810]
...
A99, 2016-12-09, P809
A99, 2016-12-09, P810

Ideas? 
The best idea I have so far is to add an extra column that is "call number" as an extra variable: 
ID, date, problem-code, call-number
A44, 2016-12-09, P809, 73
A44, 2016-12-09, P810, 73
...
A99, 2016-12-09, P809, 97
A99, 2016-12-09, P810, 98

Which might work, but then it breaks the each row is an observation (in the sense that it was a single phonecall). I guess the observation would be "problem code", and "call number" would be an observed value?
 A: Hadley defines tidy data as data where "each variable is a column, each observation is a row." It seems like you have four relevant variables in your dataset: ID, Date, problem-code, and call-number. So your idea to gather the problem codes so that each row is a unique ID x Date x problem-code x call-number is correct as long as the call-number indexes the ID x Date x problem-code combinations. In fact, if you can guarantee that the user makes no more than one call in any given day, the call-number column is superfluous since that row would already be uniquely defined by the ID x Date x problem-code combination.
A: How many problem codes do you have? If you have only a few, you could use a column for each problem code, like this:
ID, date, P809, P810
A44, 2016-12-09, 1, 1
...
A99, 2016-12-09, 1, 0
A99, 2016-12-09, 0, 1

Otherwise, you should use a column that identifies the phone call. Since this will allow each call to have multiple rows, you'll need to do a bit of grouping when answering questions like "how many calls did user A44 make?".
