Re: [Rd] loadings() generic in R alpha

2005-09-16 Thread Prof Brian D Ripley
On Fri, 16 Sep 2005, Paul Gilbert wrote:

> Brian
>
> It would help if I understood general principles. I thought one would
> want a case for NOT making functions generic, rather than a case for
> making them generic. Hopefully a case for why generics and methods are
> useful will not be necessary.

Making things generic

1) adds runtime cost

2) essentially fixes the signature for all time

3) needs the return value sufficiently well defined that all current uses
will not be broken by a new method.  (This was not a problem with e.g.
as.ts as everone knows the result should be a "ts" object.  But I think it
is a problem with acf and loadings.)

I would for example be unhappy with your definition of loadings() as it has
no ... argument (and S-PLUS has one in its loadings() generic).

So cases are necessary.  I am pretty sure that we have in the past agreed
that making a function generic is a Grand Feature, and we are in GFF.


> The situation with loadings() is that I construct objects where the
> loadings are in a list within a list, so the simple definition in stats
> does not work:
>
> loadings
> function (x)
> x$loadings
> 
>
> Basically this definition restricts the way in which objects can be
> constructed, so I would like it replaced by
>
> loadings <- function (x) UseMethod("loadings")
> loadings.default <- function (x) x$loadings
>
> There may be a reason for adding a ... argument, but I have been using
> this generic and methods for it in my own work for a fairly long time
> now and have not discovered one.  The change seems rather trivial, I
> have tested it extensively with my own code, and there is a fairly
> complete test suite in place for checking changes to R,  so it seems
> reasonable to me that this should be considered as a change that is
> possible in an alpha release. It would also be fairly easy to back out
> of if there are problems.
>
> The reason for needing  acf generic is the same, so that it can be use
> with more complicated objects that I construct. However, I see here that
> there are potentially more difficult problems, because the ... argument
> to the current acf (which one would want as the default method) is
> passed to plot.acf.  Here I can clearly see the reason for wanting to
> start consideration of this at an earlier point in the development cycle.
>
> Best,
> Paul
>
> Prof Brian Ripley wrote:
>
> > On Thu, 15 Sep 2005, Paul Gilbert wrote (in two separate messages)
> >
> >> Could loadings()  in R-2.2.0  please be made generic?
> >
> >
> >> Could acf()  in R-2.2.0  please be made generic?
> >
> >
> > I think it is too late in the process for this (and especially for
> > acf). In particular, it could have knock-on consequences for packages
> > and recommended packages are scheduled to be all fixed in stone by
> > next Weds.
> >
> > To consider making such functions generic we would need
> >
> > - a case
> > - discussion of what the arguments of the generic should be and what is
> >   to be specified about the return value.
> >
> > Perhaps you could raise these again with specific proposals early in
> > the developement cycle for 2.3.0.
> >
> > (We have been a little too casual about speciying what generic
> > functions should return in the past, and have got bitten as a result.
> > For example, can it be assumed that loadings() returns a matrix?)

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R's parsing of command line arguments using commandArgs()

2005-09-26 Thread Prof Brian D Ripley
On Mon, 26 Sep 2005, Marc Schwartz (via MN) wrote:

> On Fri, 2005-09-23 at 15:37 -0500, Marc Schwartz (via MN) wrote:
> > Hi all,
> >
> > I am setting up some R program files for use by our DB programmers to
> > enable them to utilize some R functions which will be called from within
> > TCL code. R has been installed on an RHEL server and R will process the
> > results of SQL queries against an Oracle database.
> >
> > In some cases, they will generate a data file to be read in and
> > processed by R, in others they will simply make the tabulated results
> > available.
> >
> > I know that I could do the SQL queries from within R, however, this is
> > the approach that has been defined for now for various reasons.
> >
> > I wanted to provide some flexibility for them, by passing some of the
> > tabulated results via command line arguments to R functions, rather than
> > via environment variables, which is easier for them to do in TCL it
> > would seem. They would create these values at run time, based upon specs
> > that I give them.
> >
> > Using the following as an example:
> >
> > $ R --slave --vanilla --args "c(5,5)" "c(.5,.5)" < RScript.R
> >
> > I can then process "c(5,5)" and "c(.5,.5)" as two arguments, via:
> >
> > Args <- commandArgs()
> >
> > where the two arguments are Args[5] and Args[6], respectively. I can
> > then of course pass these as "eval(parse(text = Args[5]))" to other R
> > functions.
> >
> >
> > However, if there is any whitespace in the two arguments, such as:
> >
> > R --slave --vanilla --args "c(5, 5)" "c(.5, .5)" < RScript.R
> >
> > even though surrounded by double quotes (or single quotes or
> > backquotes), the two arguments are parsed as four.
> >
> > Is this behavior expected? I was under the impression, from other C
> > based programs and bash shell scripts for example, that the use of the
> > double quotes would wrap such text and thus be parsed as a single
> > argument.

Sort of.  Unfortunately both the R front-end script and the R executable
get to play here, so once the front-end has parsed the args the quoting
gets lost.  You might hope that double quoting would help, but it does not.

> >
> > This is using:
> >
> > Version 2.1.1 Patched (2005-09-22) on FC4.
>
>
> Apologies for replying to my own post here, but I wanted to follow up
> with a solution provided by Robert McGehee, which works here.
>
> The solution is as follows:
>
> echo "a <- c(5, 5); b <- c(0.5, 0.5)" | cat - RScript.R | R --slave \
> --vanilla
>
>
> This uses echo and cat to pre-pend the 'a' and 'b' vector assignments to
> the R program file, before passing the whole thing to R.
>
> This then allows for arguments with embedded whitespace to be passed as
> required at run time.
>
> Thanks Robert!
>
> Marc
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] function to remove attributes?

2007-01-30 Thread Prof Brian D Ripley
On Tue, 30 Jan 2007, Tamas K Papp wrote:

> Hi,
>
> I would like to know if there is a compact way to remove attributes
> from an object.  I know attributes(obj) <- NULL works, but I wonder if
> there is something similar to unclass or unname.  RSiteSearch didn't
> reveal anything.

as.vector is usually used for this purpose, but note the caveat on the help 
page.  (And if you have a classed object you probably do not want to remove 
all attributes, since class is one.)

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] curious package behaviors under cross-build and/or between windows/unix

2007-04-18 Thread Prof Brian D Ripley
On Wed, 18 Apr 2007, Hin-Tak Leung wrote:

> Hi,
>
> I have gone back to cross-compiling again, and I have come to two
> curious issues: (I have native R under linux x86_64 and win32 R
> under wine) - both 2.4.1:
>
> (1) for a pure R package (i.e. no compiled code), win32 R would
> happily load the unix version, but the unix version complains
> the cross-built package that it was built for x86 mingw and refuses
> to load it. Is there any reason for the difference?

Yes.  Take a look at the installed DESCRIPTION file, and the Built: line. 
(One reason is line endings: not everything works on Unix (diff, for one) 
with CRLF endings, but everything does work on Windows with LF endings.)

> (2) I get two "arguments in definition changed from (obj) to (object)"
> messages when I do library(XML) on win32 R - but not on native R,

I get it on all platforms with 2.5.0 RC and later (2.4.x is closed), and it 
is a bug in the XML package, AFAICS.

> I know R-devel is not for asking omegahat questions, but
> the message seem to be emitted by R core, so for some reason win32 R is
> behaving differently from native linux R. Again, why the difference
> in behavior?
>
> Thanks for an ideas.
>
> Hin-Tak Leung
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] termplot with uniform y-limits

2007-07-02 Thread Prof Brian D Ripley

Is the attached the sort of thing you are looking for?
It allows ylim to be specified, including as "common".

On Mon, 2 Jul 2007, [EMAIL PROTECTED] wrote:


Does anyone have, or has anyone ever considered making, a version of
'termplot' that allows the user to specify that all plots should have
the same y-limits?

This seems a natural thing to ask for, as the plots share a y-scale.  If
you don't have the same y-axes you can easily misread the comparative
contributions of the different components.

Notes: the current version of termplot does not allow the user to
specify ylim.  I checked.

  the plot tools that come with mgcv do this by default.  Thanks
Simon.


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] simple C function segfaults

2006-02-21 Thread Prof Brian D Ripley
On Tue, 21 Feb 2006, Simon Urbanek wrote:

>
> On Feb 21, 2006, at 2:48 PM, Bernd Kriegstein wrote:
>
>> Thank you very much for the answer. As a general principle, when
>> and why should I register the counters?
>
> "register int i" is merely an optimization, you can safely use "int
> i" instead. The "register" keyword only tells the compiler to store
> the variable in a CPU register where possible - it is not necessary
> at all (most modern compiler will optimize it correctly anyway).

I actually think you should leave this off with an optimizing compiler. 
They are better at optimizing register use than humans!  I believe there 
are only a few dozen `register' statements in the R code base, almost all 
of which are in code borrowed or generated (e.g. gram.c).

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] insert insertRow?

2006-07-21 Thread Prof Brian D Ripley
[Moved to R-devel, the appropriate list for discussing development of R.]

You can do what you ask for (but micEcon does not provide) more easily and 
efficiently by indexing, and learning the power of R's indexing seems an 
important part of mastering the tool.

BTW, as a data frame is thought of as like a table in a RDBMS, so very 
little you do with one depends on the ordering of rows and columns, both of 
which are normally accessed by name.

To insert a row after idx, use something like

NewDF <- OldDF[c(1:idx, idx, (idx+1):nrow(OldDF),]
NewDF[idx+1,] <-  value of new row (as a list)
row.mames(NewDF)[idx+1] <- new row name (length-1 character vector)

On Fri, 21 Jul 2006, Marjo en Edwin wrote:

> Dear all,
>
> In the search for a command to insert a row between other rows in a data
> frame I found that there seems to be no such command in the base R
> package. There is however a very simple function insertRow in the
> micEcon package, that makes use of rbind. I wondered if it would not be
> possible to include the following micEcon functions in the base package:
>
> insertRow
> insertCol

But insertRow is for a *matrix* and not for a *data frame*, and the former 
is a rather easier task.

> Since the functions are already there, I would gather this is not a very
> big effort. It would save people that just want to insert rows and
> columns easily to install another two packages (since micEcon needs
> systemfit) or defining the functions themselves.
>
> I hope my suggestion will be taken into consideration. Whether it will
> be adopted or not, I still think R is a fantastic statistical package
> that I love to use.

We are concerned about bloat, and also the maintenance load of adding 
convenience functions to R.  My view is that they are often just another 
thing for users to learn and possibly misunderstand, as seems to be the 
case here.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] demo names with spaces?

2006-09-13 Thread Prof Brian D Ripley
There are two issues here:

1) file names with spaces are not supported, and indeed you cannot
install such a package on Windows.  Because make is used, this is
pretty fundamental.

2) The parsing code for 00Index used by 'check' assumes whitespace 
separates the name and the title.  In index files generated by R the 
separator is a tab, but demo indices are hand-crafted.

You can use underlines in the file and demo names.

On Wed, 13 Sep 2006, Dominick Samperi wrote:

> Does R support demo names with spaces?
>
> I tried placing a file like "My Demo Name.R" in
> the demo subdirectory, and placing a line that
> begins with "My Demo Name" in 00Index, but
> R CMD check does not like this. It reads the
> line in 00Index as "My, and it doesn't think there
> is a 00Index entry for "My Demo Name".
>
> I have no problem going back to MyDemoName.R,
> but I'm curious to know if there is support for
> names containing spaces.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problem tracking down an R CMD check syntax error

2006-10-20 Thread Prof Brian D Ripley

On Fri, 20 Oct 2006, Ulrike Grömping wrote:



My original post got slightly messed up somehow, so let me restructure it in
order to make it understandable:

Dear all,

I am stuck with tracking down an error I get from R CMD check (Windows, R
2.4.0, same error for R 2.2.1): when running R CMD check over a modified
version of package relaimpo, I get the following output in install.out:

preparing package relaimpo for lazy loading
Loading required package: MASS
Loading required package: boot
Error in parse(file, n, text, prompt) : syntax error at
2193:
}
2194:
Error: unable to load R code in package 'relaimpo'
Execution halted
make: *** [lazyload] Error 1
*** Installation of relaimpo failed ***

I've tracked down the "}" in question, and it is in the file zzz.R that
hasn't been changed for ages and works without problems in the current
version of the package. I include this file below. Does anyone have a hint
for me where I should look for the root cause of the problem ?


Earlier files: this is after concatenating all the files.

Check for missing final newlines on all the files, and that you can 
source() them individually.




Regards, Ulrike

## file zzz.R which gets blamed #
.onLoad <- function(lib, pkg){
   if(!require(MASS, quietly = TRUE))
    stop("Could not load package MASS")
   if(!require(boot, quietly = TRUE))
    stop("Could not load package boot")
   if(!require(methods, quietly = TRUE))
    stop("Could not load package methods")

cat("This is the non-US version of package relaimpo including the metric
pmvd.","\n")
cat("Please make sure that you are entitled to using it.","\n")
cat("If you are a US-user, please use the global version (without pmvd) that
is available on CRAN.","\n")

#cat("This is the global version of package relaimpo.","\n")
#cat( "If you are a non-US user, a version with the interesting additional
metric pmvd is available","\n")
#cat("from Ulrike Groempings web site at www.tfh-berlin.de/~groemp.","\n")

}

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

--
View this message in context: 
http://www.nabble.com/Problem-tracking-down-an-R-CMD-check-syntax-error-tf2481045.html#a6920950
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Building R from the source

2006-11-11 Thread Prof Brian D Ripley
On Sat, 11 Nov 2006, Benilton Carvalho wrote:

> Hi Everyone,
>
> when building (say) R-2.4.0 from the source, is it still the
> recommendation to use GCC 3.4?

It depends on your unstated OS.  There are recommendations in the R-admin 
manual, and those I wrote are still current.

Often one cannot easily mix systems based on gcc3 and gcc4: there are a lot 
of API incompatibilities, at least on 64-bit systems.  So if you have a 
gcc4-based Linux distribution (for example), use its 'native' compilers.

If you want more detailed advice, please give fuller details including 
your exact OS and what compilers you have available to you.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel