question with load all my package by using “devtools”

Package (under development): ACRER computer: iMAC (OS X 10.15.7) RStudio version: 1.4.1717 R version: 4.1.0 The package "ACRER" has a main script "Wageningen_SQLite_2020.R" and 4 functions (Run_Queries.R,Wcombinations.R,Wexpected_visit_duration.R and Wcrosstab.R with 4 sub functions:NGroup0.R, NGroup1.R,NGroup2.R, NGroup3.R and NGroup4.R) After running "load_all" on my package in RStudio with "devools" I got at the end some conflicts with my own R functions (eg. NGroup0() masks NGroup0()) followed with the following question: Did you accidentally source a file rather than using load_all()? (see reprex code bellow). I have used devtools for load_all and this question has no sense in my opinion at all. I will appreciate if somebody can make clear to me about this subject.

devtools::load_all(path = "/Volumes/Aias/ACRER", reset = TRUE, 
    export_all = TRUE, helpers = TRUE, quiet = FALSE)
#> ℹ Loading ACRER
#> Loading required package: usethis
#> Loading required package: ggplot2
#> Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
#> Please cite ggmap if you use it! See citation("ggmap") for details.
#> Loading required package: proto
#> 
#> Attaching package: 'kableExtra'
#> The following objects are masked from 'package:flextable':
#> 
#>     as_image, footnote
#> Loading required package: mice
#> 
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following objects are masked from 'package:base':
#> 
#>     cbind, rbind
#> * miceadds 3.11-6 (2021-01-21 11:48:47)
#> 
#> Attaching package: 'pkgload'
#> The following objects are masked from 'package:devtools':
#> 
#>     has_tests, load_all, package_file
#> 
#> Attaching package: 'pander'
#> The following object is masked from 'package:htmltools':
#> 
#>     p
#> 
#> Attaching package: 'pracma'
#> The following object is masked from 'package:doBy':
#> 
#>     taylor
#> The following object is masked from 'SciViews:TempEnv':
#> 
#>     Fix
#> 
#> Attaching package: 'reshape2'
#> The following objects are masked from 'package:data.table':
#> 
#>     dcast, melt
#> 
#> Attaching package: 'testthat'
#> The following object is masked from 'package:dplyr':
#> 
#>     matches
#> The following object is masked from 'package:purrr':
#> 
#>     is_null
#> The following object is masked from 'package:tidyr':
#> 
#>     matches
#> The following object is masked from 'package:devtools':
#> 
#>     test_file
#> Wcrosstab(Rmatrix = RmatrixA, Cmatrix = CmatrixA, C1 = C1A)
#> `summarise()` has grouped output by 'activity_pattern'. You can override using the `.groups` argument.
#> Wcrosstab(Rmatrix = RmatrixB, Cmatrix = CmatrixB, C1 = C1B)
#> `summarise()` has grouped output by 'groupsRecr_act_ts'. You can override using the `.groups` argument.
#> Warning in xtfrm.data.frame(x): cannot xtfrm data frames
#> Wcrosstab(Rmatrix = RmatrixC, Cmatrix = CmatrixC, C1 = C1C)
#>      choicenr choicetxt                                        
#> [1,] "1"      "Pivot table for the number of persons"          
#> [2,] "2"      "Pivot tables for the expected visiting duration"
#> [3,] "3"      "Save tables in csv format files"                
#> [4,] "4"      "Exit"                                           
#>    RecrID                   recreation_areas
#> 1       1           Beeldengalerij Het Depot
#> 2       2                 Arboretum Belmonte
#> 3       3         Wageningen Berg en Bergpad
#> 4       4               Arboretum de Dreijen
#> 5       5              Uitwaarden Wageningen
#> 6       6                    Renkums Beekdal
#> 7       7     Utrechtse Heuvelrug_Grebbeberg
#> 8       8                    De Blauwe Kamer
#> 9       9        Ouwehands Dierenpark Rhenen
#> 10     10                  Kasteel Doorwerth
#> 11     11                          Edese bos
#> 12     12        AIRBORNE MUSEUM HARTENSTEIN
#> 13     13            Peppelenburg Westerrode
#> 14     14                   Landgoed Kernhem
#> 15     15                     Wekeromse Zand
#> 16     16                          De Betuwe
#> 17     17                             Roekel
#> 18     18         Hoog en Laag Amerongse Bos
#> 19     19                       Noord Ginkel
#> 20     20              Amerongse Bovenpolder
#> 21     21                 Lunters Buurtbosch
#> 22     22                          WARNSBORN
#> 23     23                     PARK ZYPENDAAL
#> 24     24                        Zuid Ginkel
#> 25     25  HET NATIONALE PARK DE HOGE VELUWE
#> 26     26                        BURGERS ZOO
#> 27     27                      PARK SONSBEEK
#> 28     28     HET NEDERLANDS OPENLUCHTMUSEUM
#> 29     29                  PARK ANGERENSTEIN
#> 30     30          PARK EN KASTEEL ROSENDAEL
#> 31     31 Nationaal Park_Utrechtse Heuvelrug
#> 32     32                    GROESBEEKSE BOS
#> 33     33          VELUWETRANSFERIUM POSBANK
#>   transport_type_ID transport_type_definition maximum_of_total_time
#> 1                 1                   on foot                    60
#> 2                 2                   bicycle                    50
#> 3                 3                       car                    40
#>   wait_time_per_full_travel minimum_distance_used maximum_distance_used
#> 1                         0                     0                     0
#> 2                         0                     0                    25
#> 3                         0                     0                   100
#>   speed_of_transport_type fixed_costs_per_transport_type
#> 1                       0                              0
#> 2                      20                              0
#> 3                      60                              0
#>   per_km_costs_per_transport_type per_person_costs_per_transport_type
#> 1                            0.00                                   0
#> 2                            0.00                                   0
#> 3                            0.65                                   0
#>   per_km_en_per_person_costs_per_transport_type
#> 1                                             0
#> 2                                             0
#> 3                                             0
#> Warning: 
#> ── Conflicts ──────────────────────────────────────────────── ACRER conflicts ──
#> x NGroup0() masks ACRER::NGroup0()
#> x NGroup1() masks ACRER::NGroup1()
#> x NGroup2() masks ACRER::NGroup2()
#> … and 7 more
#> 
#> Did you accidentally source a file rather than using `load_all()`?
#> Run `rm(list = c("NGroup0", "NGroup1", "NGroup2", "NGroup3", "NGroup4", "Run_Queries", "Wcombinations", "Wcrosstab", "Wexpected_visit_duration", "WInstallPackages"))` to remove the conflicts.

Hi,

That message at the end is to indicate you are loading a package which has functions with the same name as functions already existing in your global environment. This is usually the case if you have sourced/run the functions before running devtools::load_all(). The warning is there because otherwise it can lead to some surprising behaviour where you are using a function but its definition is different to what is shown in your global environment.
As the warning suggests, if you remove the conflicts from your global environment with rm before you load your package, you will no longer get the warning.

Hope that helps.

1 Like

Thank you for your suggestion. I cleared the workspace the Environment and History of my RStudio, I restart R and without loading any file of my package I run in the console devtools::load_all(path="/Volumes/Aias/ACRER", reset = TRUE, helpers = TRUE, quiet = FALSE) but unfortunately I got the same warnings (see the reprex output):

devtools::load_all(path = "/Volumes/Aias/ACRER", reset = TRUE, 
    helpers = TRUE, quiet = FALSE)
#> ℹ Loading ACRER
#> Warning in rm(list = c("Wcombinations", "Wcrosstab",
#> "Wexpected_visit_duration")): object 'Wcombinations' not found
#> Warning in rm(list = c("Wcombinations", "Wcrosstab",
#> "Wexpected_visit_duration")): object 'Wcrosstab' not found
#> Warning in rm(list = c("Wcombinations", "Wcrosstab",
#> "Wexpected_visit_duration")): object 'Wexpected_visit_duration' not found
#> Loading required package: usethis
#> Loading required package: ggplot2
#> Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
#> Please cite ggmap if you use it! See citation("ggmap") for details.
#> Loading required package: proto
#> 
#> Attaching package: 'kableExtra'
#> The following objects are masked from 'package:flextable':
#> 
#>     as_image, footnote
#> Loading required package: mice
#> 
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following objects are masked from 'package:base':
#> 
#>     cbind, rbind
#> * miceadds 3.11-6 (2021-01-21 11:48:47)
#> 
#> Attaching package: 'pkgload'
#> The following objects are masked from 'package:devtools':
#> 
#>     has_tests, load_all, package_file
#> 
#> Attaching package: 'pander'
#> The following object is masked from 'package:htmltools':
#> 
#>     p
#> 
#> Attaching package: 'pracma'
#> The following object is masked from 'package:doBy':
#> 
#>     taylor
#> The following object is masked from 'SciViews:TempEnv':
#> 
#>     Fix
#> 
#> Attaching package: 'reshape2'
#> The following objects are masked from 'package:data.table':
#> 
#>     dcast, melt
#> 
#> Attaching package: 'testthat'
#> The following object is masked from 'package:dplyr':
#> 
#>     matches
#> The following object is masked from 'package:purrr':
#> 
#>     is_null
#> The following object is masked from 'package:tidyr':
#> 
#>     matches
#> The following object is masked from 'package:devtools':
#> 
#>     test_file
#> Wcrosstab(Rmatrix = RmatrixA, Cmatrix = CmatrixA, C1 = C1A)
#> `summarise()` has grouped output by 'activity_pattern'. You can override using the `.groups` argument.
#> Wcrosstab(Rmatrix = RmatrixB, Cmatrix = CmatrixB, C1 = C1B)
#> `summarise()` has grouped output by 'groupsRecr_act_ts'. You can override using the `.groups` argument.
#> Warning in xtfrm.data.frame(x): cannot xtfrm data frames
#> Wcrosstab(Rmatrix = RmatrixC, Cmatrix = CmatrixC, C1 = C1C)
#>      choicenr choicetxt                                        
#> [1,] "1"      "Pivot table for the number of persons"          
#> [2,] "2"      "Pivot tables for the expected visiting duration"
#> [3,] "3"      "Save tables in csv format files"                
#> [4,] "4"      "Exit"                                           
#>    RecrID                   recreation_areas
#> 1       1           Beeldengalerij Het Depot
#> 2       2                 Arboretum Belmonte
#> 3       3         Wageningen Berg en Bergpad
#> 4       4               Arboretum de Dreijen
#> 5       5              Uitwaarden Wageningen
#> 6       6                    Renkums Beekdal
#> 7       7     Utrechtse Heuvelrug_Grebbeberg
#> 8       8                    De Blauwe Kamer
#> 9       9        Ouwehands Dierenpark Rhenen
#> 10     10                  Kasteel Doorwerth
#> 11     11                          Edese bos
#> 12     12        AIRBORNE MUSEUM HARTENSTEIN
#> 13     13            Peppelenburg Westerrode
#> 14     14                   Landgoed Kernhem
#> 15     15                     Wekeromse Zand
#> 16     16                          De Betuwe
#> 17     17                             Roekel
#> 18     18         Hoog en Laag Amerongse Bos
#> 19     19                       Noord Ginkel
#> 20     20              Amerongse Bovenpolder
#> 21     21                 Lunters Buurtbosch
#> 22     22                          WARNSBORN
#> 23     23                     PARK ZYPENDAAL
#> 24     24                        Zuid Ginkel
#> 25     25  HET NATIONALE PARK DE HOGE VELUWE
#> 26     26                        BURGERS ZOO
#> 27     27                      PARK SONSBEEK
#> 28     28     HET NEDERLANDS OPENLUCHTMUSEUM
#> 29     29                  PARK ANGERENSTEIN
#> 30     30          PARK EN KASTEEL ROSENDAEL
#> 31     31 Nationaal Park_Utrechtse Heuvelrug
#> 32     32                    GROESBEEKSE BOS
#> 33     33          VELUWETRANSFERIUM POSBANK
#>   transport_type_ID transport_type_definition maximum_of_total_time
#> 1                 1                   on foot                    60
#> 2                 2                   bicycle                    50
#> 3                 3                       car                    40
#>   wait_time_per_full_travel minimum_distance_used maximum_distance_used
#> 1                         0                     0                     0
#> 2                         0                     0                    25
#> 3                         0                     0                   100
#>   speed_of_transport_type fixed_costs_per_transport_type
#> 1                       0                              0
#> 2                      20                              0
#> 3                      60                              0
#>   per_km_costs_per_transport_type per_person_costs_per_transport_type
#> 1                            0.00                                   0
#> 2                            0.00                                   0
#> 3                            0.65                                   0
#>   per_km_en_per_person_costs_per_transport_type
#> 1                                             0
#> 2                                             0
#> 3                                             0
#> Warning: 
#> ── Conflicts ──────────────────────────────────────────────── ACRER conflicts ──
#> x Wcombinations()            masks ACRER::Wcombinations()
#> x Wcrosstab()                masks ACRER::Wcrosstab()
#> x Wexpected_visit_duration() masks ACRER::Wexpected_visit_duration()
#> x WInstallPackages()         masks ACRER::WInstallPackages()
#> 
#> Did you accidentally source a file rather than using `load_all()`?
#> Run `rm(list = c("Wcombinations", "Wcrosstab", "Wexpected_visit_duration", "WInstallPackages"))` to remove the conflicts.

Created on 2021-07-05 by the reprex package (v2.0.0)

In that case, you might either be defining functions twice or there is a problem with the structure of your package. You mention you have a 'main script' for your package - not sure what you mean by that but if you are doing something like calling library at any point or creating anything other than a function then that might be what the issue is. It's hard to say without seeing the contents of your package.

Regarding the package structure, I would recommend the R-Packages book: Chapter 4 Package structure and state | R Packages

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.