locf

LOCF and NOCF methods for missing data: how to plot data?

淺唱寂寞╮ 提交于 2021-02-20 03:50:21
问题 I'm working on the following dataset and its missing data: # A tibble: 27 x 6 id sex d8 d10 d12 d14 <dbl> <chr> <dbl> <dbl> <dbl> <dbl> 1 1 F 21 20 21.5 23 2 2 F 21 21.5 24 25.5 3 3 NA NA 24 NA 26 4 4 F 23.5 24.5 25 26.5 5 5 F 21.5 23 22.5 23.5 6 6 F 20 21 21 22.5 7 7 F 21.5 22.5 23 25 8 8 F 23 23 23.5 24 9 9 F NA 21 NA 21.5 10 10 F 16.5 19 19 19.5 # ... with 17 more rows I would like to fill the missiningness data via the Last Observation Carried Forward method (LOCF) and the Next

LOCF and NOCF methods for missing data: how to plot data?

戏子无情 提交于 2021-02-20 03:49:20
问题 I'm working on the following dataset and its missing data: # A tibble: 27 x 6 id sex d8 d10 d12 d14 <dbl> <chr> <dbl> <dbl> <dbl> <dbl> 1 1 F 21 20 21.5 23 2 2 F 21 21.5 24 25.5 3 3 NA NA 24 NA 26 4 4 F 23.5 24.5 25 26.5 5 5 F 21.5 23 22.5 23.5 6 6 F 20 21 21 22.5 7 7 F 21.5 22.5 23 25 8 8 F 23 23 23.5 24 9 9 F NA 21 NA 21.5 10 10 F 16.5 19 19 19.5 # ... with 17 more rows I would like to fill the missiningness data via the Last Observation Carried Forward method (LOCF) and the Next

Change maxgap for number of times a value is carried forward

笑着哭i 提交于 2020-01-06 02:38:36
问题 I have a data frame similar to the following: library(data.table) test <- data.table(data.frame("value" = c(5,NA,8,NA,NA,8,6,NA,NA,10), "locf_N" = c(1,NA,1,NA,NA,1,2,NA,NA,2)) ) In this data frame I have a variable that indicates the times I could carry forward the last observation (locf_N). This is not a fixed number for all observations. I have tried to use the maxgap parameter in the na.locf function for this purpose but it is not actually what I am looking for. require(zoo) test[,value :=

Conditional imputation with LOCF

混江龙づ霸主 提交于 2019-12-24 06:54:53
问题 I've this example of longitudinal data. I need to impute 0, 999 or -1 values according to what occurs before. ID = c(1,1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6) Oxy = c(0, 999, 1, 999, 999, 0, 0, 999, 999, 0, 0, -1, 0, 999, 1, 1, -1, 1, 999, -1, 0, -1, 1,0, 999, 0) Y = c(2010,2011,2012,2013,2014,2011,2012,2013,2010,2011,2012,2010,2011, 2012,2010,2011,2012,2013,2014,2015,2016,2017, 2018,2019,2020, 2021) Oxy2 = c(0, 999, 1, 1, 1, 0, 0, 999, 999, 0, 0, -1, 0, 999, 1, 1, 1, 1, 999, -1, 0

Conditional imputation with LOCF

那年仲夏 提交于 2019-12-24 06:53:45
问题 I've this example of longitudinal data. I need to impute 0, 999 or -1 values according to what occurs before. ID = c(1,1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6) Oxy = c(0, 999, 1, 999, 999, 0, 0, 999, 999, 0, 0, -1, 0, 999, 1, 1, -1, 1, 999, -1, 0, -1, 1,0, 999, 0) Y = c(2010,2011,2012,2013,2014,2011,2012,2013,2010,2011,2012,2010,2011, 2012,2010,2011,2012,2013,2014,2015,2016,2017, 2018,2019,2020, 2021) Oxy2 = c(0, 999, 1, 1, 1, 0, 0, 999, 999, 0, 0, -1, 0, 999, 1, 1, 1, 1, 999, -1, 0

How to replace NA (missing values) in a data frame with neighbouring values

血红的双手。 提交于 2019-11-28 16:54:31
862 2006-05-19 6.241603 5.774208 863 2006-05-20 NA NA 864 2006-05-21 NA NA 865 2006-05-22 6.383929 5.906426 866 2006-05-23 6.782068 6.268758 867 2006-05-24 6.534616 6.013767 868 2006-05-25 6.370312 5.856366 869 2006-05-26 6.225175 5.781617 870 2006-05-27 NA NA I have a data frame x like above with some NA, which i want to fill using neighboring non-NA values like for 2006-05-20 it will be avg of 19&22 How do it is the question? Properly formatted your data looks like this 862 2006-05-19 6.241603 5.774208 863 2006-05-20 NA NA 864 2006-05-21 NA NA 865 2006-05-22 6.383929 5.906426 866 2006-05-23

identify consecutively overlapping segments in R

大城市里の小女人 提交于 2019-11-28 03:23:32
问题 I need to aggregate overlapping segments into a single segment ranging all connected segments . Note that a simple foverlaps cannot detect connections between non overlapping but connected segments, see the example for clarification. If it would rain on my segments in my plot I am looking for the stretches of dry ground. So far I solve this problem by an iterative algorithm but I'm wondering if there is a more elegant and stright forward way for this problem. I'm sure not the first one to

How to replace NA (missing values) in a data frame with neighbouring values

会有一股神秘感。 提交于 2019-11-27 10:10:16
问题 862 2006-05-19 6.241603 5.774208 863 2006-05-20 NA NA 864 2006-05-21 NA NA 865 2006-05-22 6.383929 5.906426 866 2006-05-23 6.782068 6.268758 867 2006-05-24 6.534616 6.013767 868 2006-05-25 6.370312 5.856366 869 2006-05-26 6.225175 5.781617 870 2006-05-27 NA NA I have a data frame x like above with some NA, which i want to fill using neighboring non-NA values like for 2006-05-20 it will be avg of 19&22 How do it is the question? 回答1: Properly formatted your data looks like this 862 2006-05-19