From baptiste.auguie at googlemail.com  Thu Aug 19 07:41:27 2010
From: baptiste.auguie at googlemail.com (baptiste auguie)
Date: Thu, 19 Aug 2010 07:41:27 +0200
Subject: [Rd] Automatically retrieve correct collation
In-Reply-To: <2360006184819033722@unknownmsgid>
References: <2360006184819033722@unknownmsgid>
Message-ID: <AANLkTim-o8iJ9=PdTa4AE70HytfuJHm-uyQpeyRLqG7E@mail.gmail.com>

Hi,

roxygen can create the collate field for you, if you specify the
dependencies in the commented code. I've never tested it with S4
classes though.

HTH,

baptiste

On 18 August 2010 22:28, Janko Thyson <janko.thyson at ku-eichstaett.de> wrote:
> Dear List,
>
> consider the following scenario:
>
> setClass(Class = "A", representation = representation(B = "B", C = "C"))
> setClass(Class = "B", representation = representation(C = "C"))
> setClass(Class = "C", representation = representation(something =
> "character"))
>
> Obviously, the collation for sourcing these defs needs to be: C, B, A. Which
> doesn't correspond to the default collation of R (alphabetically).
>
> I've tried to pick up on how to ensure the right collation when building R
> Packages by reading some previous posts and as far as I understand I've
> basically got two options here:
> 1) Put all class defs in one script, e.g. allClasses.R.
> 2) Manually specify the collation via the "Collate" field in the DESCRIPTION
> file.
>
> I'm used to organizing my classes, generics, methods etc. on a
> "one-per-script" basis in various subdirectories (e.g. R/classes, R/methods
> etc.) and try automate manual steps wherever possible (not sure if that's
> the way most of you guys code, but it definitely helped me stay on top of
> things). But this doesn't really go well with my two options above, does it?
> ;-)
>
> So I thought about setting up a routine that
> - investigates the source code of all classes (via parsing and looking into
> the "representation" argument)
> - finds out the valid collation by itself based on all classes that it found
> in the representation argument of the respective class defs
> - and then writes all the class defs to one R script, e.g. ?allClasses.R, so
> I can bundle all my code in an R Package without worrying about the
> collation.
>
> This way I could stick to my old habits while automating the process of
> building a package a bit ;-)
>
> Now, I managed to get this done for "simple" class defs like the ones above
> but haven't looked into more complex class defs (e.g. including "contains"
> etc.) yet.
>
> Has anyone tried and succeeded in doing something similar or are all of you
> into the "one-script-contains-all" paradigm? If anyone is interested, I'd be
> glad to share code. Likewise I'd be interested in hearing about other "best
> practices" in this respect.
>
> Best regards,
> Janko
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
____________________

Dr. Baptiste Augui?

Departamento de Qu?mica F?sica,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617
http://webs.uvigo.es/coloides



[Rd] Automatically retrieve correct collation
baptiste auguie