From wdunlap at tibco.com  Mon Dec 12 21:54:50 2016
From: wdunlap at tibco.com (William Dunlap)
Date: Mon, 12 Dec 2016 12:54:50 -0800
Subject: [Rd] [R-pkg-devel] accessing data by packagename::dataname from
 within package code fails.
In-Reply-To: <CAAjnpdjdaVn6DcTzs9echKg4XFCGBXt2FVqZBMnFM6VPOc4=4w@mail.gmail.com>
References: <CAAjnpdh91sMKbUYk6Tv8CYEJs9jA+Ztc2msEzsnJwX422nPVtw@mail.gmail.com>
	<CAAjnpdjdaVn6DcTzs9echKg4XFCGBXt2FVqZBMnFM6VPOc4=4w@mail.gmail.com>
Message-ID: <CAF8bMcY-OgUEaC1Ajv8pubFiFZ5Xo-5YN9aXn43yhjJ8Dc1Erw@mail.gmail.com>

You can define the data in the R directory.  You can keep it all in a *.R
file
by wrapping the text of the *.csv file in quotes and using
read.table(text="quoted stuff"), as in:

theData <- read.csv(header=TRUE, text="
English,Digit
One,1
Two,2
Three,3")
N <- nrow(theData)

You need to make sure 'theData' is defined before using it so put
everything requiring
it in one file or use the Collate: directive in the DESCRIPTION file.



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Dec 12, 2016 at 12:34 PM, Witold E Wolski <wewolski at gmail.com>
wrote:

> 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
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



[Rd] [R-pkg-devel] accessing data by packagename::dataname from within package code fails.
William Dunlap