Methods Lab · Practical guide ·

How to check the key in a visit-level file

If you expect one row per participant and visit, check whether those two columns together identify each record. This exercise uses the built-in synthetic example in Data Check.

Reproduce both counts

  1. Open Data Check and select Return to the synthetic example. The file contains 60 fictitious IDs with two visits each, plus one copy of a row.
  2. Select id_sintetico as the only key. Select Confirm types and validate, then open Duplicates and rules. There are 61 repetitions after the first row for each key and 121 affected rows. IDs are expected to recur across visits.
  3. Add visita to the key and validate again. There is one repetition and there are two affected rows. Expand Data row numbers. Rows 12 and 121 appear under both Identical rows and Rows with repeated keys. The key is complete for all 121 data rows in this example.
  4. Download the HTML report from Report if you need to keep the result. The first data row is numbered 1, excluding the header. If the details say “showing 100 of 121”, the remaining 21 rows are still included in the count.

Apply the check to another file

Define what one row represents before choosing the key columns. If participants can have several measurements at one visit, check which field distinguishes them. A repeated key means two or more records share the selected combination. Check whether they are copies, different measurements or corrections before deciding what to do. If a key field is missing, review the row separately. Data Check excludes incomplete keys from the repeated-key count and never deletes rows from the CSV.

See how R’s duplicated() compares rows if you want to reproduce the check using the fields read from the file.