jwutil v1.2.3


Monthly downloads



Tools for Data Manipulation and Testing

This is a set of simple utilities for various data manipulation and testing tasks. The goal is to use core R tools well, without bringing in many dependencies. Main areas of interest are semi-automated data frame manipulation, such as converting factors in multiple binary indicator columns. There are testing functions which provide 'testthat' expectations to permute arguments to function calls. There are functions and data to test extreme numbers, dates, and bad input of various kinds which should allow testing failure and corner cases, which can be used for fuzzing your functions. The test suite has many examples of usage.



CRAN status Travis Status AppVeyor status Coverage

This is a set of simple utilities for various data manipulation and caching tasks. The goal is to use base functions well, without bringing in any dependencies. Main areas of interest are data frame manipulation, such as converting factors in multiple binary indicator columns, and disk caching of data frames (which is optionally done by date range). There are testing functions which provide testthat extensions to permute arguments to function calls.

install from CRAN


install from github


Functions in jwutil

Name Description
%eine% %in%/match equivalent for two environment arguments
drop_rows_with_na drops rows with NA values in specified fields
add_time_to_date convert separate lists of dates and times to POSIXlt objects
countNonNaCumulative running totals of number of non-NA values in consecutive fields
affixFields update a set of data frame field names
env_to_vec_flip return a new environment with names and values swapped
countNotNumeric count non-numeric elements
fastIntToString Fast convert integer vector to character vector
fastIntToStringRcpp Convert integers to strings as quickly as possible
combn_subset all unique combinations of a vector and all its non-zero subsets
isValidTime check if a time is valid in 24h clock
is_numeric_str Which elements of a character vector are numeric
get_numeric_char_field_names Find columns which are numeric
opt_binary_brute selects columns from a data frame using an optimization function
%nin% inverse of %in%
is_na_ish Determine whether a value is, or should be, `NA`
jw_df_basics minimal basic pre-processing metrics
getDropped get items or numerics that would be dropped in a merge
countIsNa count NA in vector
get_factor_fields get names of the factor fields in a data frame
fix_na_ish Fix NA-like strings to be NA (or other value of choice)
is.Date is the object a Date
invwhich inverse which
flattenList flatten a list
lsf list all functions in a package
ls.objects Summarize objects
percent_signif Return percentage string to given significant figures
lsos show largest objects
lsp List all items in a package
filter_better filter data with diagnostics
fillMissingCombs fill out missing combinations of factors with NA
isFlat determine whether a list is nested
get_na_fields get NA field names from data frame
source_purl Extract code from knitr vignette and source it
sort_clip_char Take clipboard contents, and write sorted character vector back
update_github_pkgs Update github_install packages
isRowSorted is every row sorted?
get_non_ASCII mimic the R CMD check test
list_named Make a list using input argument names as names
as_numeric_nowarn convert factor or vector to numeric without warnings
as_char_no_warn convert to character vector without warning
platformIsLinux Are we running on Linux, Mac or Windows?
jw_scan_build Build with current Makevars, but with clang scan-build static analysis
jwutil-package Tools for testing and data manipulation not found elsewhere
random_test_dates generate random Dates or POSIXlt test datetimes
logical_to_binary Convert logical columns of data frame to 0s and 1s
vec_to_env_true create environment from vector
merge_better Merge better
listTrim trim null or empty values from a list
read_xlsx_linux read .xlsx file, interpret as CSV, and return a data frame
random_test_numbers create extreme random numbers
min_r_version Find minimum R version required for package
propNaPerField return proportion of NA values per field
countNumeric count numeric elements
propRowSorted proportion of non-descending rows in matrix
reqinst Load packages with library, installing any which are missing
rm_r recursive remove
listTrimFlat trim null or empty values from a list
propIsNa Proportion of NA values in a vector
dput_expect_equal dput a testthat test
trim strip whitespace from ends of each string in given character vector
str_extract stringr does this, but here we have a small amount of base R code
str_match_all return all matches for regular expression
two_cat_to_logical Take dataframe, and convert any columns with just two categories into logical
match_multi Match across columns for multiple lookup values
read_zip_url read file from zip at URL
str_multi_match return the actual matches from a bracketed regex
str_pair_match Match pairs of strings to get named vector
zero_na Zero NA values in a data.frame
zeroes zeroes
mergeLists merge lists by names
permuteWithRepeats Generate all permutations of input, reusing values in each result row
factor_nosort Fast Factor Generation
factor_to_df Convert factor into a data.frame of logicals
npc Print integers with percentage of total rounded to integer
pgo_bench Compile and test package with and without profile guided optimization
numbers_to_long_and_float convert numbers to long and float types
percentize Convert a number into rounded integer percentage string
strip strip all whitespace
strip_for_formula strip a string so that it can be used as a variable name in a formula.
permute Generate all permutations of input
save_in_data_dir Save given variable in package data directory
shuffle Shuffle a vector
unzip_single unzip a single file from URL
unzip_to_data_raw Unzip file to data-raw
bang_dollar Get the first/only argument of the last run command
bad_input bad input data for tests
expect_that_combine_all_args alternative expect_that from testthat which permutes all the inputs to a function which should give the same result where n args >=2 and the function is commutative.
binary_col_names names of fields which are numeric, binary or combinations thereof
build_formula build simple linear formula from variable names
extreme_numbers extreme numbers
drop_duplicate_fields Drop fields with duplicate data
No Results!

Vignettes of jwutil

No Results!

Last month downloads


License GPL-3
URL https://github.com/jackwasey/jwutil
BugReports https://github.com/jackwasey/jwutil/issues
LinkingTo Rcpp, testthat
VignetteBuilder knitr
Encoding UTF-8
Language en-US
NeedsCompilation yes
Packaged 2019-05-06 18:09:38 UTC; waseyj
Repository CRAN
Date/Publication 2019-05-06 19:10:03 UTC

Include our badge in your README