r - How to check the consistency of specific variables from different IDs registered repeated times in a dataframe -
i know how can detect if different individuals captured repeated times have same value in specific variables along different measures. specifically, have repeated measures of individuals (column id) values of different variables along time (e.g. sex, weight) i check individuals assigned time same sex, having reference last measure because measure reliable. later store every row or register mismatch references in 1 dataframe. id <- c("1", "2", "3", "1", "2", "3", "1", "2", "3") sex <- c("m", "f", "m", "m", "m", "m", "f", "f", "m") weight <- c(20, 15, 30, 22, 18, 32, 26, 21, 36) time <- c(1, 1, 1, 2, 2, 2, 3, 3, 3) df <- data.frame (id, sex, weight, time) df to that, have selected last register of each id library (data.table) dt <- as.data.table (df) dt_last_register <- dt [...