def calc_beats(data, rpeak_locs, metrics):
    """Returns the times when R-peaks occur

    Args:
        data (2D numpy array): contains two columns with time and ECG data
        rpeak_locs (1D numpy array): contains locations of R-peaks
        metrics (dict): dictionary containing the metrics calculated
            by this program.

    Returns:
        numpy array: dictionary with added field for heart beat times
    """

    time = data[:, 0]
    beat_time = time[rpeak_locs]

    metrics['beats'] = list(beat_time)

    return metrics