Skip to content

stRoke 23.9.1

Choose a tag to compare

@agdamsbo agdamsbo released this 07 Sep 19:43

Functions:

  • NEW: chunks_of_n() uses split() to separate supplied vector or data frame into chunks of n. Flags to set if all but the last chunks should be exactly size n, or if they should be evenly sized of max n. Labels can be provided including regex pattern for subject naming to include in chunk names.

  • NEW: n_chunks() is the opposite of chunks_of_n() and is simply a wrapper for this function to create list of n chunks based of provided vector or data frame.

  • NEW: str_extract() will extract the substring of a character string given by a regex pattern. Came to be as a helper function for labelling chunks in chunks_of_n(), but will be useful on its own. Other functions doing the same exists, but this is my take only using base R. Draws on REDCapCAST::strsplitx(), where splits can be performed around a pattern.

  • NEW: add_padding() was created out of frustration. I wanted to add padding using sprintf("%0s",string), in examples for the above, but it would fail when rendering on Windows. Say hello to another function. Just very small. Defaults to adding leading zeros, to get all string to equal length with the longer string supplied.

  • Deprecation: ds2dd() moved to REDCapCAST::ds2dd() as this is where it belongs.