Skip to content

v1.5.0

Compare
Choose a tag to compare
@msberends msberends released this 01 Jun 14:05
· 20 commits to master since this release
  • New function format_names() to quickly and easily change names of data.frame columns, lists or character vectors.

    format_names(df, snake_case = TRUE)
    format_names(df, c(old.name = "new_name", value = "measurement"))
    
    library(dplyr)
    starwars %>% 
      format_names(camelCase = TRUE) %>% # column names
      mutate(name = name %>% 
               format_names(snake_case = TRUE)) # values in column
  • New generic function na_replace() to replace NA values in any data type. Its default replacement value is dependent on the data type that is given as input: 0 for numeric values and class matrix, FALSE for class logical, today for class Date, and "" otherwise.

    na_replace(c(1, 2, NA, NA))
    #> [1] 1 2 0 0
    na_replace(c(1, 2, NA, NA), replacement = -1)
    #> [1]  1  2 -1 -1
    
    library(dplyr)
    starwars %>% 
      na_replace(hair_color) # only replace NAs in this column
      
    starwars %>% 
      na_replace() # replace NAs in all columns ("" for hair_color and 0 for birth_year)
  • Support for the upcoming R 4.1.0