On 06/27/2017 05:19 PM, Arman Sh wrote:

I’m developing  a package in which there are multiple functions that are 
dependent to each other. I have saved the functions in separate R files. When I 
run functions in correct order, I can easily get the output, but cmd check 
returns error. How can I prevent the error?

Clean up the simple stuff first



* checking package dependencies ... NOTE
Depends: includes the non-default packages:
  'cgdsr' 'xlsxjars' 'xlsx' 'gplots' 'RColorBrewer' 'rafalib' 'Biobase'
  'genefilter'
Adding so many packages to the search path is excessive and importing
selectively is preferable.

only include packages that the end-user would need to invoke in the Depends: field, otherwise use Imports:



* checking R code for possible problems ... NOTE
...
Undefined global functions or variables:
  Stop colorRampPalette dev.off head i median na.omit png
  setTxtProgressBar simplifiction.cuttoff txtProgressBar
Consider adding
  importFrom("grDevices", "colorRampPalette", "dev.off", "png")
  importFrom("stats", "median", "na.omit")
  importFrom("utils", "head", "setTxtProgressBar", "txtProgressBar")
to your NAMESPACE file.

do as the instructions say and add the suggested statements to the NAMESPACE file.



* checking Rd line widths ... NOTE
Rd file 'heatmapOutput.Rd':
  \usage lines wider than 90 characters:
heatmapOutput(submissionName, shortenStudyNames = TRUE, genelimit = "none", resolution = 600, RowCex = 0.8, ColCex = 0.8, heatmapMargines = c(10,10), angleForYaxisNames = 45, heatmapColor = "RdBu", reverseColor = TRUE,

wrap the lines to 90 characters max (80 is the norm, for easy reading in a plain terminal).



Your problem though likely comes from these

Found the following assignments to the global environment:
File 'cbaf/R/cbaf-automatedStatistics.R':
  assign(paste("Pa.PrData.", submissionName, sep = ""), newParameters,
    envir = globalenv())
...

It is VERY BAD PRACTICE to assign variables to the global environment, for exactly the reason you experience in your code -- the successful execution of your functions depends in a very precise and fragile way on the order in which they are called.

Make sure your functions are true 'functions' that rely ONLY on the input values and symbols defined or imported into the package. One possible approach is to return the parameter values as an object (e.g., an S4 class) that is then required for input into other functions.

Martin



Best regards,
Arman



==> devtools::check()

Updating cbaf documentation
Loading cbaf
Loading required package: cgdsr
Loading required package: xlsxjars
Loading required package: rJava
Loading required package: xlsx
Loading required package: gplots

Attaching package: 'gplots'

The following object is masked from 'package:stats':

     lowess

Loading required package: RColorBrewer
Loading required package: rafalib
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
     clusterExport, clusterMap, parApply, parCapply, parLapply,
     parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:rJava':

     anyDuplicated, duplicated, sort, unique

The following objects are masked from 'package:stats':

     IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

     anyDuplicated, append, as.data.frame, cbind, colMeans, colnames,
     colSums, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
     grepl, intersect, is.unsorted, lapply, lengths, Map, mapply, match,
     mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
     rbind, Reduce, rowMeans, rownames, rowSums, sapply, setdiff, sort,
     table, tapply, union, unique, unsplit, which, which.max, which.min

Welcome to Bioconductor

     Vignettes contain introductory material; view with
     'browseVignettes()'. To cite Bioconductor, see
     'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: genefilter
Setting env vars --------------------------------------------------------------
CFLAGS  : -Wall -pedantic
CXXFLAGS: -Wall -pedantic
Building cbaf -----------------------------------------------------------------
"C:/PROGRA~1/R/R-34~1.0/bin/x64/R" --no-site-file --no-environ --no-save  \
   --no-restore --quiet CMD build "Z:\cbaf\Source code\cbaf" --no-resave-data  \
   --no-manual

* checking for file 'Z:\cbaf\Source code\cbaf/DESCRIPTION' ... OK
* preparing 'cbaf':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'cbaf_0.99.0.tar.gz'

Setting env vars --------------------------------------------------------------
_R_CHECK_CRAN_INCOMING_ : FALSE
_R_CHECK_FORCE_SUGGESTS_: FALSE
Checking cbaf -----------------------------------------------------------------
"C:/PROGRA~1/R/R-34~1.0/bin/x64/R" --no-site-file --no-environ --no-save  \
   --no-restore --quiet CMD check  \
   "C:\Users\Arman\AppData\Local\Temp\RtmpoZ2dZa/cbaf_0.99.0.tar.gz" --as-cran  
\
   --timings --no-manual

* using log directory 'Z:/cbaf/Source code/cbaf.Rcheck'
* using R version 3.4.0 (2017-04-21)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* using options '--no-manual --as-cran'
* checking for file 'cbaf/DESCRIPTION' ... OK
* this is package 'cbaf' version '0.99.0'
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... NOTE
Depends: includes the non-default packages:
   'cgdsr' 'xlsxjars' 'xlsx' 'gplots' 'RColorBrewer' 'rafalib' 'Biobase'
   'genefilter'
Adding so many packages to the search path is excessive and importing
selectively is preferable.
* 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 whether package 'cbaf' can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking 'build' 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 loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... NOTE
automatedStatistics: no visible global function definition for
   'txtProgressBar'
automatedStatistics: no visible global function definition for 'head'
automatedStatistics: no visible global function definition for
   'na.omit'
automatedStatistics: no visible global function definition for 'median'
automatedStatistics: no visible global function definition for
   'setTxtProgressBar'
availableData: no visible global function definition for
   'txtProgressBar'
availableData : <anonymous>: no visible global function definition for
   'setTxtProgressBar'
heatmapOutput: no visible global function definition for
   'txtProgressBar'
heatmapOutput: no visible binding for global variable
   'simplifiction.cuttoff'
heatmapOutput: no visible global function definition for
   'colorRampPalette'
heatmapOutput: no visible global function definition for 'png'
heatmapOutput: no visible global function definition for 'dev.off'
heatmapOutput: no visible global function definition for
   'setTxtProgressBar'
obtainMultipleStudies: no visible global function definition for
   'txtProgressBar'
obtainMultipleStudies: no visible binding for global variable 'i'
obtainMultipleStudies: no visible global function definition for
   'setTxtProgressBar'
obtainOneStudy: no visible global function definition for
   'txtProgressBar'
obtainOneStudy: no visible global function definition for
   'setTxtProgressBar'
xlsxOutput: no visible global function definition for 'Stop'
xlsxOutput: no visible global function definition for 'txtProgressBar'
xlsxOutput: no visible global function definition for
   'setTxtProgressBar'
Undefined global functions or variables:
   Stop colorRampPalette dev.off head i median na.omit png
   setTxtProgressBar simplifiction.cuttoff txtProgressBar
Consider adding
   importFrom("grDevices", "colorRampPalette", "dev.off", "png")
   importFrom("stats", "median", "na.omit")
   importFrom("utils", "head", "setTxtProgressBar", "txtProgressBar")
to your NAMESPACE file.

Found the following assignments to the global environment:
File 'cbaf/R/cbaf-automatedStatistics.R':
   assign(paste("Pa.PrData.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Pa.PrData.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("PrData.", submissionName, sep = ""), processedList,
     envir = globalenv())
File 'cbaf/R/cbaf-availableData.R':
   assign(outputName, combined.list, envir = globalenv())
File 'cbaf/R/cbaf-heatmapOutput.R':
   assign(paste("Pa.Heat.", submissionName, sep = ""), newParameters,
     envir = globalenv())
File 'cbaf/R/cbaf-obtainMultipleStudies.R':
   assign(paste("Pa.Ob.Mu.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Pa.Ob.Mu.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Ob.Mu.", submissionName, sep = ""), rawList, envir = 
globalenv())
   assign(paste("Va.Mu.", submissionName, sep = ""), validationResult,
     envir = globalenv())
File 'cbaf/R/cbaf-obtainOneStudy.R':
   assign(paste("Pa.Ob.Si.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Pa.Ob.Si.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Ob.Si.", submissionName, sep = ""), rawList, envir = 
globalenv())
   assign(paste("Va.Si.", submissionName, sep = ""), validationResult,
     envir = globalenv())
File 'cbaf/R/cbaf-xlsxOutput.R':
   assign(paste("Pa.Excel.", submissionName, sep = ""), newParameters,
     envir = globalenv())
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... NOTE
Rd file 'heatmapOutput.Rd':
   \usage lines wider than 90 characters:
      heatmapOutput(submissionName, shortenStudyNames = TRUE, genelimit = 
"none", resolution = 600, RowCex = 0.8,
      ColCex = 0.8, heatmapMargines = c(10,10), angleForYaxisNames = 45, heatmapColor = 
"RdBu", reverseColor = TRUE,

Rd file 'obtainMultipleStudies.Rd':
   \usage lines wider than 90 characters:
      obtainMultipleStudies(genesList, submissionName, studiesNames, 
desiredTechnique, cancerCode = FALSE, validateGenes = TRUE)
   \examples lines wider than 100 characters:
      studies <- c("Acute Myeloid Leukemia (TCGA, Provisional)", "Adrenocortical 
Carcinoma (TCGA, Provisional)")

Rd file 'obtainOneStudy.Rd':
   \usage lines wider than 90 characters:
      obtainOneStudy(genesList, submissionName, studyName, desiredTechnique, 
desiredCaseList = FALSE, validateGenes = TRUE)

Rd file 'processMultipleStudies.Rd':
   \usage lines wider than 90 characters:
      processMultipleStudies(genesList, submissionName, studiesNames, 
desiredTechnique, cancerCode = FALSE,
      validateGenes = TRUE, calculate = c("frequencyPercentage", "frequencyRatio", 
"meanValue", "medianValue"), cutoff=NULL,
      round=TRUE, topGenes = TRUE, shortenStudyNames = TRUE, genelimit = 
"none", resolution = 600, RowCex = 0.8, ColCex = 0.8,
      heatmapMargines = c(10,10), angleForYaxisNames = 45, heatmapColor = 
"RdBu", reverseColor = TRUE, transposedHeatmap = FALSE,
   \examples lines wider than 100 characters:
      studies <- c("Acute Myeloid Leukemia (TCGA, Provisional)", "Adrenocortical 
Carcinoma (TCGA, Provisional)")
      processMultipleStudies(genes, "test", studies, "RNA-seq", calculate = 
c("Frequency.Percentage", "Frequency.Ratio", "Mean.Value"))

Rd file 'processOneStudy.Rd':
   \usage lines wider than 90 characters:
      processOneStudy(genesList, submissionName, studyName, desiredTechnique, 
desiredCaseList = FALSE,
      validateGenes = TRUE, calculate = c("frequencyPercentage", "frequencyRatio", 
"meanValue", "medianValue"), cutoff=NULL,
      round=TRUE, topGenes = TRUE, shortenStudyNames = TRUE, genelimit = 
"none", resolution = 600, RowCex = 0.8, ColCex = 0.8,
      heatmapMargines = c(10,10), angleForYaxisNames = 45, heatmapColor = 
"RdBu", reverseColor = TRUE, transposedHeatmap = FALSE,
   \examples lines wider than 100 characters:
      desired.case.list = c(3,4,5), data.presented.as = c("Frequency.Percentage", 
"Frequency.Ratio", "Mean.Value"))

These lines will be truncated in the PDF manual.
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
  WARNING
'qpdf' is needed for checks on size reduction of PDFs
* checking installed files from 'inst/doc' ... OK
* checking files in 'vignettes' ... OK
* checking examples ... ERROR
Running examples in 'cbaf-Ex.R' failed
The error most likely occurred in:

base::assign(".ptime", proc.time(), pos = "CheckExEnv")
### Name: heatmapOutput
### Title: Generating heatmaps for various studies/subgroups of a study.
### Aliases: heatmapOutput

### ** Examples

heatmapOutput(submissionName = "test")
Error in heatmapOutput(submissionName = "test") :
   Please run automatedStatistics() function first
Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in 'inst/doc' ... OK
* checking re-building of vignette outputs ... OK
* DONE
Status: 1 ERROR, 1 WARNING, 3 NOTEs

See
   'Z:/cbaf/Source code/cbaf.Rcheck/00check.log'
for details.

checking examples ... ERROR
Running examples in 'cbaf-Ex.R' failed
The error most likely occurred in:

base::assign(".ptime", proc.time(), pos = "CheckExEnv")
### Name: heatmapOutput
### Title: Generating heatmaps for various studies/subgroups of a study.
### Aliases: heatmapOutput

### ** Examples

heatmapOutput(submissionName = "test")
Error in heatmapOutput(submissionName = "test") :
   Please run automatedStatistics() function first
Execution halted

checking package dependencies ... NOTE
Depends: includes the non-default packages:
   'cgdsr' 'xlsxjars' 'xlsx' 'gplots' 'RColorBrewer' 'rafalib' 'Biobase'
   'genefilter'
Adding so many packages to the search path is excessive and importing
selectively is preferable.

checking R code for possible problems ... NOTE
automatedStatistics: no visible global function definition for
   'txtProgressBar'
automatedStatistics: no visible global function definition for 'head'
automatedStatistics: no visible global function definition for
   'na.omit'
automatedStatistics: no visible global function definition for 'median'
automatedStatistics: no visible global function definition for
   'setTxtProgressBar'
availableData: no visible global function definition for
... 57 lines ...
File 'cbaf/R/cbaf-obtainOneStudy.R':
   assign(paste("Pa.Ob.Si.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Pa.Ob.Si.", submissionName, sep = ""), newParameters,
     envir = globalenv())
   assign(paste("Ob.Si.", submissionName, sep = ""), rawList, envir = 
globalenv())
   assign(paste("Va.Si.", submissionName, sep = ""), validationResult,
     envir = globalenv())
File 'cbaf/R/cbaf-xlsxOutput.R':
   assign(paste("Pa.Excel.", submissionName, sep = ""), newParameters,
     envir = globalenv())

checking Rd line widths ... NOTE
Rd file 'heatmapOutput.Rd':
   \usage lines wider than 90 characters:
      heatmapOutput(submissionName, shortenStudyNames = TRUE, genelimit = 
"none", resolution = 600, RowCex = 0.8,
      ColCex = 0.8, heatmapMargines = c(10,10), angleForYaxisNames = 45, heatmapColor = 
"RdBu", reverseColor = TRUE,

Rd file 'obtainMultipleStudies.Rd':
   \usage lines wider than 90 characters:
      obtainMultipleStudies(genesList, submissionName, studiesNames, 
desiredTechnique, cancerCode = FALSE, validateGenes = TRUE)
   \examples lines wider than 100 characters:
... 16 lines ...

Rd file 'processOneStudy.Rd':
   \usage lines wider than 90 characters:
      processOneStudy(genesList, submissionName, studyName, desiredTechnique, 
desiredCaseList = FALSE,
      validateGenes = TRUE, calculate = c("frequencyPercentage", "frequencyRatio", 
"meanValue", "medianValue"), cutoff=NULL,
      round=TRUE, topGenes = TRUE, shortenStudyNames = TRUE, genelimit = 
"none", resolution = 600, RowCex = 0.8, ColCex = 0.8,
      heatmapMargines = c(10,10), angleForYaxisNames = 45, heatmapColor = 
"RdBu", reverseColor = TRUE, transposedHeatmap = FALSE,
   \examples lines wider than 100 characters:
      desired.case.list = c(3,4,5), data.presented.as = c("Frequency.Percentage", 
"Frequency.Ratio", "Mean.Value"))

These lines will be truncated in the PDF manual.
R CMD check results
1 error  | 0 warnings | 3 notes

R CMD check succeeded



        [[alternative HTML version deleted]]

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel



This email message may contain legally privileged and/or...{{dropped:2}}

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to