v1.5.0
-
New function
format_names()
to quickly and easily change names ofdata.frame
columns,list
s orcharacter
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 replaceNA
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 classmatrix
,FALSE
for classlogical
, today for classDate
, 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