0

I have been making a package to upload to CRAN, but I have a little trouble.

If you go to the website, https://github.com/elflacosebas/migraR, you will find the package.

You can run the example to test it.

The problem comes when I want to avoid the attach and perform the best_migramod function. Then, it will use inside fit_migramod, which uses a class named Migramodel.

You can run the example now without the line codes below:

colnames(data1) <- c("x","y")

attach(data1)

The error I get says:

Error in eval(.self$expr, c(as.list(p), as.list(data))) : object 'x' not finded

I have tried using attach and detach to solve it into the best_migradmod function but it doesn't work. I understand it is a matter of environment as this post says as well.

Error in eval(expr, envir, enclos) : object not found

Where shoud I put the attach? or the other operators, or should I modify the data file? or

Thanks a lot for the hint!!

El Flaco
  • 13
  • 3
  • 4
    `attach` is not recommended. If you want to extract the variables, use `[[` or `$` or using `with` – akrun Dec 09 '19 at 13:13
  • in particular not within packages – Roland Dec 09 '19 at 13:14
  • akrun yes, but I have check it, but if you see attach is out the package, I have seen the functions but I've been trying in different ways... where to put the [[ $ or with? – El Flaco Dec 09 '19 at 14:08

1 Answers1

0

In my laptop work the example without the two lines that you mentioned

sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362)

Matrix products: default

Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding

locale: [1] LC_COLLATE=Spanish_Colombia.1252 LC_CTYPE=Spanish_Colombia.1252 LC_MONETARY=Spanish_Colombia.1252 [4] LC_NUMERIC=C LC_TIME=Spanish_Colombia.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] migraR_0.1.2 devtools_2.2.1 usethis_1.5.1 dplyr_0.8.3

loaded via a namespace (and not attached): [1] Rcpp_1.0.2 rstudioapi_0.10 magrittr_1.5 tidyselect_0.2.5 pkgload_1.0.2 R6_2.4.0
[7] rlang_0.4.2 tools_3.6.0 pkgbuild_1.0.6 sessioninfo_1.1.1 cli_1.1.0 withr_2.1.2
[13] remotes_2.1.0 ellipsis_0.3.0 rprojroot_1.3-2 assertthat_0.2.1 digest_0.6.20 tibble_2.1.3
[19] crayon_1.3.4 processx_3.4.1 purrr_0.3.3 callr_3.3.1 fs_1.3.1 ps_1.3.0
[25] curl_4.0 testthat_2.3.1 memoise_1.1.0 glue_1.3.1 compiler_3.6.0 pillar_1.4.2
[31] backports_1.1.4 desc_1.2.0 prettyunits_1.0.2 pkgconfig_2.0.2

cesc13
  • 21
  • 2
  • Could the packages change depending on the configuration of the pc's? that is another question to add to this develop. Thanks Cesc13. – El Flaco Jan 13 '20 at 15:31