Skip to contents

For easy readability, we want to use consistent coding style when developing code for framrsquared. Presently this includes (a) using <- for assignment, and (b) using snakecase for variable and function names. The functions here streamlining checking R code for consistency with this style.

Usage

frs_stylecheck_assignment(filepath, n = Inf)

frs_stylecheck_snakecase(filepath, n = Inf)

Arguments

filepath

Path to R file to be checked

n

Number of rows to print. Default is to print all rows, but set to smaller values if output is overwhelming.

Details

frs_stylecheck_assignment() takes the path to an R file, and prints (and returns) any rows that may be mis-using the = for assignment. Note that it will give false positives for arguments defined in function calls if the call spans multiple lines, as well as = signs included in character strings.

frs_stylecheck_snakecase takes the path to an R file and prints (and returns) the names of any variables assigned using <- that do not include underscores. This will identify variables that do not use snakecase, but will also give false positive matches for variables that are single words and thus do not need snakecase.

Examples

if (FALSE) { # \dontrun{
frs_stylecheck_assignment("R/copy.R")
frs_stylecheck_snakecase("R/copy.R")
} # }