[R-pkg-devel] If Your Function Require API Key Input, How to get around check errors as the key is not provided?

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Fri Jun 3 22:18:57 CEST 2022



On 2022-06-03 4:00 p.m., Edward Wei wrote:
> When releasing a package, API Keys are not supposed to be available for
> those who download it. However, the package I am building requires the API
> key to be able to pull the data for the examples. Should I just comment out
> the examples so the error doesn't come?
> 
>> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
>> ### Name: crypto60
>> ### Title: Get Cryptocurrency Data at the hourly level localized to current
>> ###   time zone
>> ### Aliases: crypto60
>>
>> ### ** Examples
>>
>> crypto60("BTC")
> Error: Set API key using av_api_key(). If you do not have an API key,
> please claim your free API key on
> (https://www.alphavantage.co/support/#api-key). It should take less
> than 20 seconds, and is free permanently.
> Execution halted
> * checking PDF version of manual ... OK
> * checking for detritus in the temp directory ... OK
> * DONE
> Status: 1 ERROR, 3 NOTEs
> 
> To resolve errors, one would simply have to run
> av_api_key("YOUR_AV_KEY_HERE")
> before running any queries. Is there a way to provide a key for testing but
> at the same time mask it from those who would potentially download your
> package? Or is there a way to not have these functions (that require API
> key to pull data) be subject to the test for spitting out errors.
> 
> Another "problem"  I am running into is the following.:It is a NOTE but I
> am new at this and not sure whether or not I would need to resolve it for a
> submission.
> 
> * checking R code for possible problems ... [8s] NOTE
> addreturns: no visible binding for global variable 'returns'
> addreturns: no visible binding for global variable 'idreturns'
> addreturns: no visible binding for global variable 'tot_ret'
> addreturns: no visible binding for global variable 'high'
> addreturns: no visible binding for global variable 'low'
> get60: no visible binding for global variable 'a'
> project_price: no visible binding for global variable 'hs'
> volatility_freq: no visible binding for global variable 'high'
> volatility_freq: no visible binding for global variable 'low'
> volatility_freq: no visible binding for global variable 'hilow'
> volatilty_freq_cum: no visible binding for global variable 'high'
> volatilty_freq_cum: no visible binding for global variable 'low'
> volatilty_freq_cum: no visible binding for global variable 'hilow'
> Undefined global functions or variables:
>    a high hilow hs idreturns low returns tot_ret
> 
> All of the variables that have been named are defined within the functions
> I am building. They do not and should not exist outside the function. I do
> not think this is a problem I really need to resolve for a successful
> submission. Is that correct?

    Based on past experience you *will* need to address this note for a 
successful CRAN submission.  These notes are presumably caused by the 
use of non-standard-evaluation (these days typically tidyverse-based). 
You can either use `globalVariables` or assign the values to NULL near 
the top of your function ...

> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics



More information about the R-package-devel mailing list