Re: [R] R CMD methods and ggplot2 advice

2015-05-28 Thread Rolf Turner

On 27/05/15 23:37, Thierry Onkelinx wrote:

Dear Glenn,

Suppose this function

test - function(df){
   ggplot(df, aes(x = gp, y = y)) + geom_point()
}

Then R CMD check will consider gp and y as global variables since they are
undefined. Because R CMD check cannot detect that gp and y will be
extracted from df by ggplot2.

Possible workarounds

# now gp and y are defined within the function. ggplot2 still looks for gp
and y in df.
test - function(df){
   gp - NULL
   y - NULL
   ggplot(df, aes(x = gp, y = y)) + geom_point()
}

# now gp and y are strings and hence defined
test - function(df){
   ggplot(df, aes_string(x = gp, y = y)) + geom_point()
}


SNIP

Why not use utils::globalVariables?

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R CMD methods and ggplot2 advice

2015-05-28 Thread Thierry Onkelinx
Dear Rolf,

utils::globalVariables() seems to work package wide. I prefer to ignore
these variable only within the function in which I explicitly define them.
If I use one of those variables in another function in which I haven't
declared them as global, then I want R CMD check to give me a NOTE.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie  Kwaliteitszorg / team Biometrics  Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-05-28 11:28 GMT+02:00 Rolf Turner r.tur...@auckland.ac.nz:

 On 27/05/15 23:37, Thierry Onkelinx wrote:

 Dear Glenn,

 Suppose this function

 test - function(df){
ggplot(df, aes(x = gp, y = y)) + geom_point()
 }

 Then R CMD check will consider gp and y as global variables since they are
 undefined. Because R CMD check cannot detect that gp and y will be
 extracted from df by ggplot2.

 Possible workarounds

 # now gp and y are defined within the function. ggplot2 still looks for gp
 and y in df.
 test - function(df){
gp - NULL
y - NULL
ggplot(df, aes(x = gp, y = y)) + geom_point()
 }

 # now gp and y are strings and hence defined
 test - function(df){
ggplot(df, aes_string(x = gp, y = y)) + geom_point()
 }


 SNIP

 Why not use utils::globalVariables?

 cheers,

 Rolf Turner

 --
 Technical Editor ANZJS
 Department of Statistics
 University of Auckland
 Phone: +64-9-373-7599 ext. 88276


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R CMD methods and ggplot2 advice

2015-05-27 Thread Thierry Onkelinx
Dear Glenn,

Suppose this function

test - function(df){
  ggplot(df, aes(x = gp, y = y)) + geom_point()
}

Then R CMD check will consider gp and y as global variables since they are
undefined. Because R CMD check cannot detect that gp and y will be
extracted from df by ggplot2.

Possible workarounds

# now gp and y are defined within the function. ggplot2 still looks for gp
and y in df.
test - function(df){
  gp - NULL
  y - NULL
  ggplot(df, aes(x = gp, y = y)) + geom_point()
}

# now gp and y are strings and hence defined
test - function(df){
  ggplot(df, aes_string(x = gp, y = y)) + geom_point()
}

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie  Kwaliteitszorg / team Biometrics  Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-05-26 2:24 GMT+02:00 Glenn Schultz glennmschu...@me.com:

 Hello All,

 I have two packages Bond Lab and the Companion to Investing in MBS.  Bond
 Lab clears the check and I am working on the on.load() to copy a needed
 directory per Duncan Murdoch's advise to make Bond Lab CRAN-able.  The
 companion passes with two notes.  The output is below:

 I get two notes (highlighted in red)

 Not sure on this one as I tried to declare methods but I get another note
 methods declared but not used.  The second note is related to ggplot2 they
 are variable passed to ggplot2 within a function.  I am not sure why they
 appear in the R CMD check.  If someone could point in the right direction
 to resolve these I would appreciate the advice.  These are my last
 remaining two issues to make the packages pass CRAN aside from the on.load()

 Best Regards,
 Glenn

 * checking dependencies in R code ... NOTE
 package ‘methods’ is used but not declared


 * checking R code for possible problems ... NOTE
 CreditEnhancement: no visible binding for global variable ‘Period’
 CreditEnhancement: no visible binding for global variable ‘Value’
 CreditEnhancement: no visible binding for global variable ‘Variable’
 CreditEnhancement: no visible binding for global variable ‘..density..’
 PassThrough.OAS: no visible binding for global variable ‘value’
 PassThrough.OAS: no visible binding for global variable ‘..density..’
 PassThroughCashFlow: no visible binding for global variable ‘Period’
 PassThroughCashFlow: no visible binding for global variable ‘value’
 PassThroughCashFlow: no visible binding for global variable ‘variable’
 PlotMtgKeyRates: no visible binding for global variable ‘Tenor’
 PlotMtgKeyRates: no visible binding for global variable ‘Duration’
 PlotTermStructure: no visible binding for global variable ‘value’
 PlotTermStructure: no visible binding for global variable ‘variable’
 REMICOAS: no visible binding for global variable ‘value’
 REMICOAS: no visible binding for global variable ‘..density..’
 TotalReturn: no visible binding for global variable ‘Scenario’
 TotalReturn: no visible binding for global variable ‘value’
 TotalReturn: no visible binding for global variable ‘variable’
 TwistScenario: no visible binding for global variable ‘Scenario’
 TwistScenario: no visible binding for global variable ‘Return’
 ValuationFramework: no visible binding for global variable ‘value’
 ValuationFramework: no visible binding for global variable ‘variable’

 == devtools::check()

 Updating Companion2IMBS documentation
 Loading Companion2IMBS
 '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD build  \
   '/Users/glennschultz/Companion to Investing in MBS' --no-resave-data  \
   --no-manual

 * checking for file ‘/Users/glennschultz/Companion to Investing in
 MBS/DESCRIPTION’ ... OK
 * preparing ‘Companion2IMBS’:
 * checking DESCRIPTION meta-information ... OK
 * checking for LF line-endings in source and make files
 * checking for empty or unneeded directories
 Removed empty directory ‘Companion2IMBS/inst’
 Removed empty directory ‘Companion2IMBS/test/testthat’
 Removed empty directory ‘Companion2IMBS/test’
 * building ‘Companion2IMBS_1.0.tar.gz’

 '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD check  \

 '/var/folders/tv/sq6gmnvs13j8jrhkt87f_zmcgn/T//RtmpOabREs/Companion2IMBS_1.0.tar.gz'
  \
   --timings

 * using log directory ‘/Users/glennschultz/Companion2IMBS.Rcheck’
 * using R version 3.0.3 (2014-03-06)
 * using platform: x86_64-apple-darwin10.8.0 (64-bit)
 * using session charset: UTF-8
 * checking for file ‘Companion2IMBS/DESCRIPTION’ ... OK
 * checking extension type ... Package
 * this is package ‘Companion2IMBS’ version ‘1.0’
 * checking package 

Re: [R] R CMD methods and ggplot2 advice

2015-05-26 Thread Duncan Murdoch
This posting should probably go to the new R-package-devel mailing list
instead of R-help.  If you do re-post there, you should give more
information to let people help you.  We can see the errors, but we can't
see the source to your package, so it's hard to diagnose them.  If your
source is online somewhere, a link to it would really help.  If not,
then please include a copy of the DESCRIPTION file (so we can see how
you declared dependence on methods), and extracts from the source of
CreditEnhancement() where you use Period, etc.

Duncan Murdoch

On 25/05/2015 8:24 PM, Glenn Schultz wrote:
 Hello All,
 
 I have two packages Bond Lab and the Companion to Investing in MBS.  Bond Lab 
 clears the check and I am working on the on.load() to copy a needed directory 
 per Duncan Murdoch's advise to make Bond Lab CRAN-able.  The companion passes 
 with two notes.  The output is below:
 
 I get two notes (highlighted in red)
 
 Not sure on this one as I tried to declare methods but I get another note 
 methods declared but not used.  The second note is related to ggplot2 they 
 are variable passed to ggplot2 within a function.  I am not sure why they 
 appear in the R CMD check.  If someone could point in the right direction to 
 resolve these I would appreciate the advice.  These are my last remaining two 
 issues to make the packages pass CRAN aside from the on.load()
 
 Best Regards,
 Glenn
 
 * checking dependencies in R code ... NOTE
 package ‘methods’ is used but not declared
 
 
 * checking R code for possible problems ... NOTE
 CreditEnhancement: no visible binding for global variable ‘Period’
 CreditEnhancement: no visible binding for global variable ‘Value’
 CreditEnhancement: no visible binding for global variable ‘Variable’
 CreditEnhancement: no visible binding for global variable ‘..density..’
 PassThrough.OAS: no visible binding for global variable ‘value’
 PassThrough.OAS: no visible binding for global variable ‘..density..’
 PassThroughCashFlow: no visible binding for global variable ‘Period’
 PassThroughCashFlow: no visible binding for global variable ‘value’
 PassThroughCashFlow: no visible binding for global variable ‘variable’
 PlotMtgKeyRates: no visible binding for global variable ‘Tenor’
 PlotMtgKeyRates: no visible binding for global variable ‘Duration’
 PlotTermStructure: no visible binding for global variable ‘value’
 PlotTermStructure: no visible binding for global variable ‘variable’
 REMICOAS: no visible binding for global variable ‘value’
 REMICOAS: no visible binding for global variable ‘..density..’
 TotalReturn: no visible binding for global variable ‘Scenario’
 TotalReturn: no visible binding for global variable ‘value’
 TotalReturn: no visible binding for global variable ‘variable’
 TwistScenario: no visible binding for global variable ‘Scenario’
 TwistScenario: no visible binding for global variable ‘Return’
 ValuationFramework: no visible binding for global variable ‘value’
 ValuationFramework: no visible binding for global variable ‘variable’
 
 == devtools::check()
 
 Updating Companion2IMBS documentation
 Loading Companion2IMBS
 '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD build  \
   '/Users/glennschultz/Companion to Investing in MBS' --no-resave-data  \
   --no-manual 
 
 * checking for file ‘/Users/glennschultz/Companion to Investing in 
 MBS/DESCRIPTION’ ... OK
 * preparing ‘Companion2IMBS’:
 * checking DESCRIPTION meta-information ... OK
 * checking for LF line-endings in source and make files
 * checking for empty or unneeded directories
 Removed empty directory ‘Companion2IMBS/inst’
 Removed empty directory ‘Companion2IMBS/test/testthat’
 Removed empty directory ‘Companion2IMBS/test’
 * building ‘Companion2IMBS_1.0.tar.gz’
 
 '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD check  \
   
 '/var/folders/tv/sq6gmnvs13j8jrhkt87f_zmcgn/T//RtmpOabREs/Companion2IMBS_1.0.tar.gz'
   \
   --timings 
 
 * using log directory ‘/Users/glennschultz/Companion2IMBS.Rcheck’
 * using R version 3.0.3 (2014-03-06)
 * using platform: x86_64-apple-darwin10.8.0 (64-bit)
 * using session charset: UTF-8
 * checking for file ‘Companion2IMBS/DESCRIPTION’ ... OK
 * checking extension type ... Package
 * this is package ‘Companion2IMBS’ version ‘1.0’
 * checking package namespace information ... OK
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking if there is a namespace ... OK
 * checking for executable files ... OK
 * checking for hidden files and directories ... OK
 * checking for portable file names ... OK
 * checking for sufficient/correct file permissions ... OK
 * checking whether package ‘Companion2IMBS’ can be installed ... OK
 * checking installed package size ... OK
 * checking package directory ... OK
 * checking DESCRIPTION meta-information ... OK
 * checking top-level files ... OK
 * checking for left-over files ... OK
 * checking index information ... OK
 * checking package subdirectories ... 

[R] R CMD methods and ggplot2 advice

2015-05-25 Thread Glenn Schultz

Hello All,

I have two packages Bond Lab and the Companion to Investing in MBS.  Bond Lab 
clears the check and I am working on the on.load() to copy a needed directory 
per Duncan Murdoch's advise to make Bond Lab CRAN-able.  The companion passes 
with two notes.  The output is below:

I get two notes (highlighted in red)

Not sure on this one as I tried to declare methods but I get another note 
methods declared but not used.  The second note is related to ggplot2 they are 
variable passed to ggplot2 within a function.  I am not sure why they appear in 
the R CMD check.  If someone could point in the right direction to resolve 
these I would appreciate the advice.  These are my last remaining two issues to 
make the packages pass CRAN aside from the on.load()

Best Regards,
Glenn

* checking dependencies in R code ... NOTE
package ‘methods’ is used but not declared


* checking R code for possible problems ... NOTE
CreditEnhancement: no visible binding for global variable ‘Period’
CreditEnhancement: no visible binding for global variable ‘Value’
CreditEnhancement: no visible binding for global variable ‘Variable’
CreditEnhancement: no visible binding for global variable ‘..density..’
PassThrough.OAS: no visible binding for global variable ‘value’
PassThrough.OAS: no visible binding for global variable ‘..density..’
PassThroughCashFlow: no visible binding for global variable ‘Period’
PassThroughCashFlow: no visible binding for global variable ‘value’
PassThroughCashFlow: no visible binding for global variable ‘variable’
PlotMtgKeyRates: no visible binding for global variable ‘Tenor’
PlotMtgKeyRates: no visible binding for global variable ‘Duration’
PlotTermStructure: no visible binding for global variable ‘value’
PlotTermStructure: no visible binding for global variable ‘variable’
REMICOAS: no visible binding for global variable ‘value’
REMICOAS: no visible binding for global variable ‘..density..’
TotalReturn: no visible binding for global variable ‘Scenario’
TotalReturn: no visible binding for global variable ‘value’
TotalReturn: no visible binding for global variable ‘variable’
TwistScenario: no visible binding for global variable ‘Scenario’
TwistScenario: no visible binding for global variable ‘Return’
ValuationFramework: no visible binding for global variable ‘value’
ValuationFramework: no visible binding for global variable ‘variable’

== devtools::check()

Updating Companion2IMBS documentation
Loading Companion2IMBS
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD build  \
  '/Users/glennschultz/Companion to Investing in MBS' --no-resave-data  \
  --no-manual 

* checking for file ‘/Users/glennschultz/Companion to Investing in 
MBS/DESCRIPTION’ ... OK
* preparing ‘Companion2IMBS’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
Removed empty directory ‘Companion2IMBS/inst’
Removed empty directory ‘Companion2IMBS/test/testthat’
Removed empty directory ‘Companion2IMBS/test’
* building ‘Companion2IMBS_1.0.tar.gz’

'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD check  \
  
'/var/folders/tv/sq6gmnvs13j8jrhkt87f_zmcgn/T//RtmpOabREs/Companion2IMBS_1.0.tar.gz'
  \
  --timings 

* using log directory ‘/Users/glennschultz/Companion2IMBS.Rcheck’
* using R version 3.0.3 (2014-03-06)
* using platform: x86_64-apple-darwin10.8.0 (64-bit)
* using session charset: UTF-8
* checking for file ‘Companion2IMBS/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘Companion2IMBS’ version ‘1.0’
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘Companion2IMBS’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking dependencies in R code ... NOTE
package ‘methods’ is used but not declared
See the information on DESCRIPTION files in the chapter ‘Creating R
packages’ of the ‘Writing R Extensions’ manual.
* checking S3 generic/method consistency ... OK
* checking