Revisión | d19e932160cfac21b0d1fad1e8dffcc7bf6e1db4 (tree) |
---|---|
Tiempo | 2024-01-10 23:11:50 |
Autor | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I added a function to translate a number into a missing value.
@@ -2906,6 +2906,20 @@ | ||
2906 | 2906 | |
2907 | 2907 | } |
2908 | 2908 | |
2909 | + | |
2910 | + | |
2911 | +number_to_na <- function(df, number=0){ | |
2912 | + | |
2913 | + | |
2914 | + res <- df |> | |
2915 | + mutate(across(where(is.numeric), \(x) na_if(x, number))) | |
2916 | + | |
2917 | +return(res) | |
2918 | + | |
2919 | +} | |
2920 | + | |
2921 | + | |
2922 | + | |
2909 | 2923 | ## generic function to replace a pattern to another |
2910 | 2924 | ## (works only for an exact match) |
2911 | 2925 |