Horje
dplyr replace na Code Example
dplyr replace na
df <- tibble(x = c(1, 2, NA), y = c("a", NA, "b"))

df %>% dplyr::mutate(x = replace_na(x, 0))
#> # A tibble: 3 x 2
#>       x y    
#>   <dbl> <chr>
#> 1     1 a    
#> 2     2 NA   
#> 3     0 b

# To replace NA in two columns
df %>% replace_na(list(x = 0, y = "unknown"))
#> # A tibble: 3 x 2
#>       x y      
#>   <dbl> <chr>  
#> 1     1 a      
#> 2     2 unknown
#> 3     0 b      




R

Related
R string ascii accents Code Example R string ascii accents Code Example
mode in r Code Example mode in r Code Example
r convert accented characters Code Example r convert accented characters Code Example
linetype ggplot in r Code Example linetype ggplot in r Code Example
r how to import tsv file Code Example r how to import tsv file Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7