Error in initFields(scales = scales) : could not find function “initRefFields”

后端 未结 1 1691
情话喂你
情话喂你 2021-01-21 00:35

I have a ggplot2 plotting function as part of my code. The function works fine when the file is sourced as R code, however when I include this function in an R package (and of c

相关标签:
1条回答
  • 2021-01-21 01:05

    I think I have found a solution/workaround.

    As I noticed from sessionInfo() the methods package was not attached but rather loaded in the namespace. Therefore after attaching methods (as well as grid which was needed for a consequent function) my script work fine by oading the functions from the package.

    My working sessionInfo() looks like this now:

    R version 3.2.0 (2015-04-16)
    Platform: x86_64-apple-darwin13.4.0 (64-bit)
    Running under: OS X 10.10.3 (Yosemite)
    
    locale:
    [1] C/UTF-8/C/C/C/C
    
    attached base packages:
    [1] grid      methods   stats     graphics  grDevices utils     datasets
    [8] base
    
    other attached packages:
    [1] argparse_1.0.1 proto_0.3-10   greater_1.0
    
    loaded via a namespace (and not attached):
     [1] Rcpp_0.11.6        DEoptimR_1.0-2     RColorBrewer_1.1-2 plyr_1.8.2
     [5] class_7.3-12       prabclus_2.2-6     tools_3.2.0        digest_0.6.8
     [9] mclust_5.0.1       gtable_0.1.2       lattice_0.20-31    mvtnorm_1.0-2
    [13] findpython_1.0.1   gridExtra_0.9.1    trimcluster_0.1-2  stringr_1.0.0
    [17] cluster_2.0.1      RGraphics_2.0-12   fpc_2.1-9          stats4_3.2.0
    [21] diptest_0.75-6     nnet_7.3-9         getopt_1.20.0      robustbase_0.92-3
    [25] flexmix_2.3-13     pander_0.5.1       ggplot2_1.0.1      reshape2_1.4.1
    [29] kernlab_0.9-20     magrittr_1.5       scales_0.2.4       modeltools_0.2-21
    [33] MASS_7.3-40        colorspace_1.2-6   stringi_0.4-1      munsell_0.4.2
    [37] rjson_0.2.15
    

    Thanks very much for the contribution, however I would appreciate an explanation on firstly why there is the need to explicitly attach these two packages (methods and grid) when the functions are loaded as a package, and it is not required when the function are sourced by source().

    0 讨论(0)
提交回复
热议问题