R code for cleaning dates

data.frame(
  stringsAsFactors = FALSE,
             newid = c(1L, 2L, 3L, 4L, 5L, 6L, 6L, 5L, 5L, 5L),
     location_name = c("Facility 1","Facility 2",
                       "Facility 3","Facility 4","Facility 5","Facility 6",
                       "Facility 6","Facility 5","Facility 5","Facility 5"),
         data_date = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)
)
#>    newid location_name data_date
#> 1      1    Facility 1        NA
#> 2      2    Facility 2        NA
#> 3      3    Facility 3        NA
#> 4      4    Facility 4        NA
#> 5      5    Facility 5        NA
#> 6      6    Facility 6        NA
#> 7      6    Facility 6        NA
#> 8      5    Facility 5        NA
#> 9      5    Facility 5        NA
#> 10     5    Facility 5        NA

Created on 2024-03-12 with reprex v2.1.0

Session info

sessionInfo()
#> R version 4.3.2 (2023-10-31 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19044)
#> 
#> Matrix products: default
#> 
#> 
#> locale:
#> [1] LC_COLLATE=English_Ireland.utf8  LC_CTYPE=English_Ireland.utf8   
#> [3] LC_MONETARY=English_Ireland.utf8 LC_NUMERIC=C                    
#> [5] LC_TIME=English_Ireland.utf8    
#> 
#> time zone: Europe/Dublin
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] styler_1.10.2     digest_0.6.34     fastmap_1.1.1     xfun_0.41        
#>  [5] magrittr_2.0.3    glue_1.7.0        R.utils_2.12.3    knitr_1.45       
#>  [9] htmltools_0.5.7   rmarkdown_2.25    lifecycle_1.0.4   cli_3.6.2        
#> [13] R.methodsS3_1.8.2 vctrs_0.6.5       reprex_2.1.0      withr_3.0.0      
#> [17] compiler_4.3.2    R.oo_1.26.0       R.cache_0.16.0    purrr_1.0.2      
#> [21] rstudioapi_0.15.0 tools_4.3.2       evaluate_0.23     yaml_2.3.8       
#> [25] rlang_1.1.3       fs_1.6.3
1 Like

Hello,

Can you provide a bit more about what you are trying to do with the code? You defined the values for data_date as NA when you created the fake data.

All the best,

Tim