Recent Releases of cleaner
cleaner - v1.5.1
- New function
format_p_value()to format raw p values according to the APA guideline clean_Date()now works with POSIX standards:r clean_Date("2020-11-12 12:24:12") clean_Date(c("2020-11-12 12:24:12", "2020-11-13"), guess_each = TRUE)- Currency now prints and formats without symbols as default, use
as_symbol = TRUEto print/format with currency symbols - Support for older versions of R (v3.2)
- R
Published by msberends over 5 years ago
cleaner - v1.5.0
- New function
format_names()to quickly and easily change names ofdata.framecolumns,lists orcharactervectors. ```r formatnames(df, snakecase = TRUE) formatnames(df, c(old.name = "newname", value = "measurement"))
library(dplyr) starwars %>% formatnames(camelCase = TRUE) %>% # column names mutate(name = name %>% formatnames(snake_case = TRUE)) # values in column ```
- New generic function
na_replace()to replaceNAvalues in any data type. Its default replacement value is dependent on the data type that is given as input:0for numeric values and classmatrix,FALSEfor classlogical, today for classDate, and""otherwise. ```r nareplace(c(1, 2, NA, NA)) #> [1] 1 2 0 0 nareplace(c(1, 2, NA, NA), replacement = -1) #> [1] 1 2 -1 -1
library(dplyr) starwars %>% nareplace(haircolor) # only replace NAs in this column
starwars %>% nareplace() # replace NAs in all columns ("" for haircolor and 0 for birth_year) ``` * Support for the upcoming R 4.1.0
- R
Published by msberends about 6 years ago
cleaner - v1.4.0
- New function
rdate()to generate random dates (in analogy to e.g.runif()) - Frequency tables (
freq()):- Added availability of data to header
- Fix for using
na.rm - Fix for transforming to a visual histogram with
hist() - New method for using
format()on a frequency table - New method for transforming the values of a frequency table to a vector with
as.vector(), which also supports datesr library(dplyr) library(cleaner) data.frame(dates = rdate(100)) %>% freq(dates) %>% as.vector()
- Fix for
clean_Date()not accepting alreadyPOSIXorDateinput - When using
clean_Date(..., guess_each = TRUE)it now accepts theformatparameter as a vector of options to let it choose from clean_Date()andclean_POSIXctgained a parametermax_date(that defaults to today), so that they will never return years beyond a specified date: ```r # old clean_Date("23-01-67") #> [1] "2067-01-23"
# new
cleanDate("23-01-67")
#> [1] "1967-01-23"
#> Warning: Some years were decreased by 100 to not exceed today.
#> Use cleanDate(..., maxdate = Inf) to prevent this.
cleanDate("23-01-67", max_date = Inf)
#> [1] "2067-01-23"
``
* Cleaned all code using thelintr` package
- R
Published by msberends over 6 years ago
cleaner - v1.2.0
cleaner 1.2.0
- DUE TO CRAN POLICY: RENAMED TO PACKAGE TO
cleaner - Added support for percentages as a new class:
as.percentage()andclean_percentage(). They also come with 'S3 methods' forprint,format,sum,minandmax. - More robust coercing of dates
- Support for negative values for
clean_numeric(),clean_percentage()andclean_currency() - Fix for
clean_character()on R v3.5 and lower - Fix for digits in frequency tables for numeric values
- R
Published by msberends over 6 years ago