efficiently locf by groups in a single R data.table
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 3 years ago . I have a large, wide data.table (20m rows) keyed by a person ID but with lots of columns (~150) that have lots of null values. Each column is a recorded state / attribute that I wish to carry forward for each person. Each person may have anywhere from 10 to 10,000 observations and there are about 500,000 people in the set. Values from one person can not 'bleed' into the