What did my colleague do to prepare the data for an ICC?

We ask posters here to take care that code is properly formatted. It makes the site easier to read, prevents confusion (unformatted code can mistakenly trigger other types of automatic formatting) and generally is considered the polite thing to do. You can read all the details of how to do it here: FAQ: How to format your code

Or try the easy way :grin: : select any code (whether in blocks or in bits and pieces mixed into your sentences) and click the little </> button at the top of the posting box.


As for your question, we can only guess without the original data (or fake data in the same format). My guess is the code in question restructures the data so that each combination of id/session/segment only has one row. If it has multiple rows, each from a different coder, they're merged into a single row. It assumes there are at most two coders for each id/session/segment.

Every row of T.temp2 will have 37 columns: id, session, Segment, and then two each of whatever the other columns are. Of the pairs for the doubled columns, one will have the original name and the other will be named b_ + the original name (e.g., X and b_X).

If you want to adapt this script for your work, I'd suggest taking the concepts behind it and totally rewriting it using either the dplyr or data.table. The choice between the two usually boils down to whatever you prefer to read/write.

As is, the posted code is not idiomatic R; the purpose isn't immediately clear, bugs are more likely to pop up, and the code's likely inefficient. Despite that, if it works for your colleague, that's great. There's no reason for her to rewrite something that works and she understands. But if you're learning R, take advantage of all the shared knowledge.