Philippe Grosjean
2004-Oct-17 13:55 UTC
[R] Errors while compiling packages with namespace?
Hello,
I try to set up namespaces for packages. It is fine for several of them,
except one whose compilation fails (under Windows XP & R 2.0.0):
---------- Making package svViews ------------
adding build stamp to DESCRIPTION
installing NAMESPACE file and metadata
Error in parse(file, n, text, prompt) : syntax error on line 21
Execution halted
make[2]: *** [nmspace] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-svViews] Error 2
*** Installation of svViews failed ***
This kind of error tells me that there is something wrong in my code, making
it impossible to parse, isn't it? However, when I source the code in R,
everything is fine. Also, this package compiled without errors before I
introduced NAMESPACE. The only changes I did in the code (beside adding
NAMESPACE), is to eliminate all "require(....)" and to replace them by
"import" and "importFrom" statements in NAMESPACE. So, I
suppose this should
be due to a wrong or missing "import", or "importFrom"
directive. Does
anybody has another suggestion?
My question is: how do I know where is the error in my code, given this
message: "syntax error in line 21" while installing NAMESPACE.
Obviously, it
is not in "line 21" of any of my original code files in ./R (because I
can
source them all without error). At this point, I am completelly lost. Any
help would be welcome. This package contains several hundreds of lines of
code, and NAMESPACE is quite complex:
importFrom(svMisc, listCustoms, getTemp)
importFrom(R2HTML, HTML, HTMLhr, HTMLInsertGraph, HTMLli, HTML.cormat)
importFrom(utils, browseURL, methods)
importFrom(lattice, lset)
importFrom(MASS, lda)
import(svIO, graphics, grDevices, stats)
export(guiViewsCmd,
guiViewsCSS,
guiViewsCSSChange,
guiViewsDir,
guiViewsDisplay,
guiViewsFile,
report,
reportGraph,
viewHTMLinit)
S3method(view, default)
S3method(view, data.frame)
S3method(view, function)
S3method(view, matrix)
S3method(view, princomp)
S3method(view, trellis)
S3method(view, ts)
Thank you.
Best,
Philippe Grosjean
..............................................<??}))><........
) ) ) ) )
( ( ( ( ( Prof. Philippe Grosjean
) ) ) ) )
( ( ( ( ( Numerical Ecology of Aquatic Systems
) ) ) ) ) Mons-Hainaut University, Pentagone
( ( ( ( ( Academie Universitaire Wallonie-Bruxelles
) ) ) ) ) 6, av du Champ de Mars, 7000 Mons, Belgium
( ( ( ( (
) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.33.12
( ( ( ( ( email: Philippe.Grosjean at umh.ac.be
) ) ) ) )
( ( ( ( ( web: http://www.umh.ac.be/~econum
) ) ) ) )
..............................................................
The error message points to line 21 of the NAMESPACE file: S3method(view, function) The NAMESPACE file is parsed by the R parser, so this is a suntax error since function is a reserved word. Put quotes around it and you should be OK. luke On Sun, 17 Oct 2004, Philippe Grosjean wrote:> Hello, > > I try to set up namespaces for packages. It is fine for several of them, > except one whose compilation fails (under Windows XP & R 2.0.0): > > ---------- Making package svViews ------------ > adding build stamp to DESCRIPTION > installing NAMESPACE file and metadata > Error in parse(file, n, text, prompt) : syntax error on line 21 > Execution halted > make[2]: *** [nmspace] Error 1 > make[1]: *** [all] Error 2 > make: *** [pkg-svViews] Error 2 > *** Installation of svViews failed *** > > This kind of error tells me that there is something wrong in my code, making > it impossible to parse, isn't it? However, when I source the code in R, > everything is fine. Also, this package compiled without errors before I > introduced NAMESPACE. The only changes I did in the code (beside adding > NAMESPACE), is to eliminate all "require(....)" and to replace them by > "import" and "importFrom" statements in NAMESPACE. So, I suppose this should > be due to a wrong or missing "import", or "importFrom" directive. Does > anybody has another suggestion? > > My question is: how do I know where is the error in my code, given this > message: "syntax error in line 21" while installing NAMESPACE. Obviously, it > is not in "line 21" of any of my original code files in ./R (because I can > source them all without error). At this point, I am completelly lost. Any > help would be welcome. This package contains several hundreds of lines of > code, and NAMESPACE is quite complex: > > importFrom(svMisc, listCustoms, getTemp) > importFrom(R2HTML, HTML, HTMLhr, HTMLInsertGraph, HTMLli, HTML.cormat) > importFrom(utils, browseURL, methods) > importFrom(lattice, lset) > importFrom(MASS, lda) > > import(svIO, graphics, grDevices, stats) > > export(guiViewsCmd, > guiViewsCSS, > guiViewsCSSChange, > guiViewsDir, > guiViewsDisplay, > guiViewsFile, > report, > reportGraph, > viewHTMLinit) > > S3method(view, default) > S3method(view, data.frame) > S3method(view, function) > S3method(view, matrix) > S3method(view, princomp) > S3method(view, trellis) > S3method(view, ts) > > Thank you. > Best, > > Philippe Grosjean > > ..............................................<??}))><........ > ) ) ) ) ) > ( ( ( ( ( Prof. Philippe Grosjean > ) ) ) ) ) > ( ( ( ( ( Numerical Ecology of Aquatic Systems > ) ) ) ) ) Mons-Hainaut University, Pentagone > ( ( ( ( ( Academie Universitaire Wallonie-Bruxelles > ) ) ) ) ) 6, av du Champ de Mars, 7000 Mons, Belgium > ( ( ( ( ( > ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.33.12 > ( ( ( ( ( email: Philippe.Grosjean at umh.ac.be > ) ) ) ) ) > ( ( ( ( ( web: http://www.umh.ac.be/~econum > ) ) ) ) ) > .............................................................. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Luke Tierney University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke at stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
Hi, all:
I find survreg {survival} has provided many distributions such as weibull,
lognormal, etc. But I wonder why it doesn't have the support for gamma
distribution since it should be a good distr. in lifetime analysis. Can
anybody figure out the reason?
I've tried to implement the likelihood function of progressively censored
data for gamma distr. and use optim() to solve the paramemters. The
log-likelihood function L contains some integrations. I use tryCatch() to
capture the error when integration lead to divergence and return Inf.
But if consequent two calls to the objective function return Inf, optim()
will raise errors:
Error in optim(c(ga, 1/la), fr, method = "BFGS") :
non-finite finite-difference value [1]
What can I do except for choosing better initial values?
The last question, by its name "survreg", survreg does its job by
regression,
but why p.75 in Tableman, Kim (2004) said that "We use the S function
survReg to fit parametric models (with the MLE approach)...". Does survreg
use regression or MLE approach?
Thanks for your help.
[1] Mara Tableman, Jong Sung Kim, Survival Analysis Using S, Chapman &
Hall/CRC, 2004