timriffe / DemoTools

Tools for the evaluation, adjustment, and standardization of demographic data
https://timriffe.github.io/DemoTools
Other
61 stars 31 forks source link

Checking name of function called works with namespaces #129

Closed markalava closed 4 years ago

markalava commented 4 years ago

In many functions there is a check for the name of the called function, e.g., if (as.character(match.call()[[1]]) == "lt_single_simple") in 'R/lt_single.R'. This fails if the function is called with a namespace, e.g., DemoTools::lt_single_mx. This occurs, for example, when invoked in another package. The update attempts to fix this and, additionally, offer some support for other methods of calling via do.call.

A test for the check_heaping_whipple function has been included in file 'tests/testthat/test-fn_name_check_messages.R'.

devtools::check completed with the following message:

-- R CMD check results --------------------------------- DemoTools 01.06.02 ----
Duration: 5m 35.2s

> checking data for ASCII and uncompressed saves ... OK
   WARNING
  'qpdf' is needed for checks on size reduction of PDFs

0 errors v | 1 warning x | 0 notes v

Reference: The deparse idea is from "GavinSimpson"s comment half way down this page: https://stackoverflow.com/questions/15595478/how-to-get-the-name-of-the-calling-function-inside-the-called-routine

timriffe commented 4 years ago

merged. This is fine for now. I'll be removing those warnings, as they've been in place for about a year now since I made a bunch of name changes. Any old code will have been updated by now. Thanks for digging into it