[R-pkg-devel] RData files with identical objects in package
Troels Ring
tring @ending from gvdnet@dk
Sun Jan 13 14:13:24 CET 2019
Thanks a lot - here's is what I get:
A single object matching ‘x’ was found
It was found in the following places
package:try
with value
[1] 100
Now put in the last "xfile.RData" - and
"afile.RData" is still muted
Restarting R session...
> library(try)
> x
[1] 100
> getAnywhere("x")
A single object matching ‘x’ was found
It was found in the following places
package:try
with value
[1] 100
> data(afile)
> x
[1] 100
Whereas we know x in afile.RData is 45
So something is very wrong
Sorry to be so helpless
BW
Troels
-----Oprindelig meddelelse-----
Fra: Duncan Murdoch <murdoch.duncan using gmail.com>
Sendt: 13. januar 2019 12:46
Til: Troels Ring <tring using gvdnet.dk>; package-develop <r-package-devel using r-project.org>
Emne: Re: [R-pkg-devel] RData files with identical objects in package
On 13/01/2019 3:38 a.m., Troels Ring wrote:
> Dear friends - I have a package under creation making heavy
> calculations on chemical/clinical data and I plan to include as
> "examples" the use of some literature data used in my papers. To
> illustrate what then occurs, I made two RData files consisting only of
> x and y with different values for x and y like
>
> X <- 100
>
> Y <- 1000
>
> save(x,y,file="first.RData")
>
> and then a new x and y in "second" with x <- 45 and y <- 32
>
> When I put these in a "data" directory of a new package without
> further ado in RStudio
>
> Ctrl-shift-L
>
> Ctrl-shift-B
>
>
>
> .there is a warning
>
> * installing *source* package 'try' ...
>
> ** R
>
> ** data
>
> *** moving datasets to lazyload DB
>
> warning: objects 'x', 'y' are created by more than one data call
>
> ** byte-compile and prepare package for lazy loading
>
> ** help
>
> converting help for package 'try'
>
> *** installing help indices
>
> finding HTML links ... hello html
>
> done
>
>
>
> Now, when I clear the workspace:
>
>> ls()
> character(0)
>> devtools::load_all(".")
> Loading try
>
> Restarting R session...
>
>> library(try)
>> ls()
> character(0)
>> x #-- so even if workspace Is empty x is still kept
> [1] 45
>> data(first) # and "first" is not seen x
> [1] 45
>
>
>
> x is still present - and y
>
>
>
> I have been reading and searching in "Writing R extensions" but so far
> didn't find the clue.
>
> Seemingly it is the file with the last name that is assessed - when I rename
> first.RData to "xfile.RData" we get 100 and 1000.
>
> Now and then when running ctrl-shift-L and - B we see
>
>
>
> Attaches package: 'try'
>
> The following objects are masked _by_ '.GlobalEnv':
> x, y
>
Does that every happen when ls() returns character(0)? It seems likely
that you have copies of them in the global workspace, and the message is
correct.
In the earlier situation (ls() *does* return character(0), but x is
still found), you can find where it was found using
getAnywhere("x")
For example,
> x <- 2
> getAnywhere("x")
A single object matching ‘x’ was found
It was found in the following places
.GlobalEnv
with value
[1] 2
Duncan Murdoch
More information about the R-package-devel
mailing list