[R] Problem making a package using S4 objects.

2009-05-29 Thread Fernando Martins
Hello.

I've developed an algorithm in R which I need to package.
The implementation uses S4 objects and it's divided in 5 files.
Everything is working fine when I load the files into the R console but when
I try to make a package I get an error that I don't quite understand.

Here's what I do:

*1.* in R console, I do and get:
> package.skeleton(name='remora')
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './remora/Read-and-delete-me'.
Warning messages:
1: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R",  :
  deparse of an S4 object will not be
source()able
2: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R",  :
  deparse of an S4 object will not be
source()able
3: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R",  :
  deparse of an S4 object will not be
source()able
4: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R",  :
  deparse of an S4 object will not be source()able


I don't know why I get these warnings. I've followed R implementation rules
and the S4 objects work fine.


*2.* Performing the 'R CMD build remora' command I get:

* checking for file 'remora/DESCRIPTION' ... OK
* preparing 'remora':
* checking DESCRIPTION meta-information ... OK
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'remora_1.0.tar.gz'

And the remora_1.0.tar.gz file seems ok.

*
3.* Performing the 'R CMD check remora' command I get:

* checking for working pdflatex ...sh: pdflatex: not found
 NO
* checking for working latex ...sh: latex: not found
 NO
* using log directory '/home/fmm/thesis/R/src/remora.Rcheck'
* using R version 2.8.1 (2008-12-22)
* using session charset: UTF-8
* checking for file 'remora/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'remora' version '1.0'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'remora' can be installed ... ERROR
Installation failed.
See '/home/fmm/thesis/R/src/remora.Rcheck/00install.out' for details.

*4.* the log file contains:

* Installing *source* package 'remora'
...
**
R

**
data

** preparing package for lazy
loading
Error in parse(n = -1, file = file) : unexpected '<'
at
745: `.__C__remoraConfiguration`
<-
746:
<

Calls:  -> code2LazyLoadDB -> sys.source ->
parse
Execution
halted
ERROR: lazy loading failed for package
'remora'
** Removing
'/home/fmm/thesis/R/src/remora.Rcheck/remora'
f...@darkmaster:~/thesis/R/src$ grep -i __C__remoraConfiguration *
f...@darkmaster:~/thesis/R/src$ grep -i __C__remoraConfiguration */*
remora.Rcheck/00install.out:745: `.__C__remoraConfiguration` <-

remoraConfiguration is a constructor for the remoraConfiguration S4 object.


#
# Class configuration definition.
#
CLASS_REMORA_CONFIGURATION <- "remoraConfiguration"
class_configuration <- setClass(CLASS_REMORA_CONFIGURATION,
  representation(number_clusters = "numeric", class_name = "character",
weighting_function="character",
scale_variance="logical", s="numeric", d="numeric", alfa="numeric", eta
= "numeric", niter="numeric", niter_changes="numeric",
perform_sum="logical", verbose="logical"),
  prototype = list(number_clusters=numeric(), class_name=character(),
weighting_function=character(),
scale_variance=logical(), s=numeric(), d=numeric(), alfa=numeric(),
eta=numeric(), niter=numeric(), niter_changes=numeric(),
perform_sum=logical(), verbose=logical()))

#
# Builds a Remora configuration object.
#
# [...]
#
remoraConfiguration <- function(number_clusters, class_name,
weighting_function = FUNCTION_REMORA_EUCLIDEAN, scale_variance=TRUE, s_value
= 0.001, d = 0.3, alfa = 0.9, eta = 0.01, niter=-1, niter_changes=5,
perform_sum = TRUE, verbose=FALSE) {

  result_configuration <- new(CLASS_REMORA_CONFIGURATION)
  [...]

  result_configuration
}

I'm using R version 2.8.1 (2008-12-22).

Sorry for the long email, but I don't want to miss any important
information.

Am I doing something wrong? If so, what?
How can I overcome this problem?

Thank you very much.
-- 
Fernando Martins

http://www.vilma-fernando.net/it/"In Dreams Begin...
http://m6onsoftware.blogspot.com/  Responsability"

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem making a package using S4 objects.

2009-06-04 Thread Fernando Martins
Hello again.

I have found the answer to my own problem and I have documented it in my
blog.
Take a look at
http://m6onsoftware.blogspot.com/2009/06/r-package-with-s4-objects.html for
full story.

Hope this is useful for others.

Best regards

On Fri, May 29, 2009 at 11:54 PM, Fernando Martins wrote:

> Hello.
>
> I've developed an algorithm in R which I need to package.
> The implementation uses S4 objects and it's divided in 5 files.
> Everything is working fine when I load the files into the R console but
> when I try to make a package I get an error that I don't quite understand.
>
> Here's what I do:
>
> *1.* in R console, I do and get:
> > package.skeleton(name='remora')
> Creating directories ...
> Creating DESCRIPTION ...
> Creating Read-and-delete-me ...
> Saving functions and data ...
> Making help files ...
> Done.
> Further steps are described in './remora/Read-and-delete-me'.
> Warning messages:
> 1: In dump(internalObjs, file = file.path(code_dir,
> sprintf("%s-internal.R",  :
>   deparse of an S4 object will not be
> source()able
> 2: In dump(internalObjs, file = file.path(code_dir,
> sprintf("%s-internal.R",  :
>   deparse of an S4 object will not be
> source()able
> 3: In dump(internalObjs, file = file.path(code_dir,
> sprintf("%s-internal.R",  :
>   deparse of an S4 object will not be
> source()able
> 4: In dump(internalObjs, file = file.path(code_dir,
> sprintf("%s-internal.R",  :
>   deparse of an S4 object will not be source()able
>
>
> I don't know why I get these warnings. I've followed R implementation rules
> and the S4 objects work fine.
>
>
> *2.* Performing the 'R CMD build remora' command I get:
>
> * checking for file 'remora/DESCRIPTION' ... OK
> * preparing 'remora':
> * checking DESCRIPTION meta-information ... OK
> * removing junk files
> * checking for LF line-endings in source and make files
> * checking for empty or unneeded directories
> * building 'remora_1.0.tar.gz'
>
> And the remora_1.0.tar.gz file seems ok.
>
> *
> 3.* Performing the 'R CMD check remora' command I get:
>
> * checking for working pdflatex ...sh: pdflatex: not found
>  NO
> * checking for working latex ...sh: latex: not found
>  NO
> * using log directory '/home/fmm/thesis/R/src/remora.Rcheck'
> * using R version 2.8.1 (2008-12-22)
> * using session charset: UTF-8
> * checking for file 'remora/DESCRIPTION' ... OK
> * checking extension type ... Package
> * this is package 'remora' version '1.0'
> * checking package dependencies ... OK
> * checking if this is a source package ... OK
> * checking for executable files ... OK
> * checking whether package 'remora' can be installed ... ERROR
> Installation failed.
> See '/home/fmm/thesis/R/src/remora.Rcheck/00install.out' for details.
>
> *4.* the log file contains:
>
> * Installing *source* package 'remora'
> ...
> **
> R
>
> **
> data
>
> ** preparing package for lazy
> loading
> Error in parse(n = -1, file = file) : unexpected '<'
> at
> 745: `.__C__remoraConfiguration`
> <-
> 746:
> <
>
> Calls:  -> code2LazyLoadDB -> sys.source ->
> parse
> Execution
> halted
> ERROR: lazy loading failed for package
> 'remora'
> ** Removing
> '/home/fmm/thesis/R/src/remora.Rcheck/remora'
> f...@darkmaster:~/thesis/R/src$ grep -i __C__remoraConfiguration *
> f...@darkmaster:~/thesis/R/src$ grep -i __C__remoraConfiguration */*
> remora.Rcheck/00install.out:745: `.__C__remoraConfiguration` <-
>
> remoraConfiguration is a constructor for the remoraConfiguration S4 object.
>
>
> #
> # Class configuration definition.
> #
> CLASS_REMORA_CONFIGURATION <- "remoraConfiguration"
> class_configuration <- setClass(CLASS_REMORA_CONFIGURATION,
>   representation(number_clusters = "numeric", class_name = "character",
> weighting_function="character",
> scale_variance="logical", s="numeric", d="numeric", alfa="numeric", eta
> = "numeric", niter="numeric", niter_changes="numeric",
> perform_sum="logical", verbose="logical"),
>   prototype = list(number_clusters=numeric(), class_name=character(),
> weighting_function=character(),
> scale_variance=logical(), s=numeric(), d=numeric(), alfa=numeric(),
> eta=numeric(), niter=numeric(), niter_changes=numeric(),
> perform_sum=logical(), verbose=logical()))
>
>