From wewolski at gmail.com  Mon Dec 12 21:34:36 2016
From: wewolski at gmail.com (Witold E Wolski)
Date: Mon, 12 Dec 2016 21:34:36 +0100
Subject: [Rd] accessing data by packagename::dataname from within
	package code fails.
In-Reply-To: <CAAjnpdh91sMKbUYk6Tv8CYEJs9jA+Ztc2msEzsnJwX422nPVtw@mail.gmail.com>
References: <CAAjnpdh91sMKbUYk6Tv8CYEJs9jA+Ztc2msEzsnJwX422nPVtw@mail.gmail.com>
Message-ID: <CAAjnpdjdaVn6DcTzs9echKg4XFCGBXt2FVqZBMnFM6VPOc4=4w@mail.gmail.com>

I have narrowed down the problem.
The error
Error : 'AminoAcids' is not an exported object from 'namespace:bibliospec'
Error : unable to load R code in package 'bibliospec'

occurs only if I try to access the data using bibliospec::AminoAcids

within the initialize method of an R reference class.
It does work, as far as I tested everywhere else. In other methods of
a reference class as well as in free functions.
It also does not work in the initialization list to the initialize function.
So I also can't do something like
initialize = function(aminoAcids=bibliospec::AminoAcids){


I guess this is an R FEATURE.

But then where and how is the best practice to initialize class
members with default values?

Thank you.





On 12 December 2016 at 15:45, Witold E Wolski <wewolski at gmail.com> wrote:
> I am wrting a package called bibliospec.
> I have a dataset in data/AminoAcids.tsv and would like to be able to
> access it with
>
> bibliospec::AminoAcids
>
> from within my package code.
>
> R CMD build gives me the error:
> Error : 'AminoAcids' is not an exported object from 'namespace:bibliospec'
>
> I am able to access the data in package code with
> data(AminoAcids)
> AminoAcids
>
> but this will give me a NOTE with R CMD check
>
> Also, after loading the packagepackage I am able to access the data with
> bibliospec::AminoAcids
>
> But I can't access it from the package bibliospec code.
> So why can't I access bibliospec::AminoAcids from within package code?
>
> Help appreciated
>
> Witold
> --
> Witold Eryk Wolski



-- 
Witold Eryk Wolski



[Rd] accessing data by packagename::dataname from within package code fails.
Witold E Wolski