On 1/25/20 12:55, Gábor Csárdi wrote:
> R CMD build does not actually run any R code,

**unless** the package contains dynamic vignettes and/or dynamic man 
pages (e.g. man pages that include \Sexpr macros), in which case 'R CMD 
build' first installs the package in order to evaluate the dynamic stuff 
and then puts all the files together in a .tar.gz archive (including the 
evaluated vignette and man pages).

Just wanted to clarify.

Best,
H.

> it just puts the files
> together into a .tar.gz archive.
> 
> R CMD INSTALL will run the R code, and fail.
> 
> Gabor
> 
> On Sat, Jan 25, 2020 at 4:59 PM Andy Manka <andy.ma...@gmail.com> wrote:
>>
>>
>> If you start a function in one file but don't close it, the package
>> will still build if you manage to close it in a later file. Like so:
>>
>> a.R
>> b.R
>> c.R
>>
>> a.R:
>> function_a <- function(){
>>    print("this is function_a")
>> }
>>
>> b.R:
>> function_b <- function(){
>>    print("unclosed function_b")
>> # no closing }
>>
>> c.R:
>> function_c <- function(){
>>    print("function_c will be part of function_b")
>> }
>> #extra closing } to close function_b
>> }
>>
>> --------
>>
>> The package builder will import `a.R` and `b.R`. And because
>> function_b was never closed, `c.R` gets subsumed into function_b. It's
>> pretty hard to debug, and it means that a production implementation
>> depends on the file structure never changing. (If you define a
>> function across `b.R` and `d.R`, you can never add an R script that
>> starts with `c`.)
>>
>> What's the benefit of letting functions be defined across files in the
>> package builder? Or is it an unintended side effect?
>>
>> I suspect the code for all this is in:
>> /src/library/tools/R/build.R
>>
>> but it's beyond me.
>>
>> The command I ran is:
>> "C:\Program Files\R\R-3.6.2\bin\x64\Rcmd.exe" build "c:\path\to\package"
>>
>> ______________________________________________
>> R-devel@r-project.org mailing list
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=EooPdH2zxyGemkIijLeOEhTnbHj2ZnF752zkuL2oH78&s=k7-iYyWapTxOuYwiVvt93bBNtx_2FjuXZYP-Ids9ypU&e=
> 
> ______________________________________________
> R-devel@r-project.org mailing list
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=EooPdH2zxyGemkIijLeOEhTnbHj2ZnF752zkuL2oH78&s=k7-iYyWapTxOuYwiVvt93bBNtx_2FjuXZYP-Ids9ypU&e=
> 

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to