Re: [Rd] Bug in R evaluating a huge instruction (PR#14096)

2009-12-03 Thread Jean Couteau


FWIW the restriction is only on the console input - if you send it 
directly, there is no limit (I have never heard of nuiton-j2r but if 
you use rJava to interface from Java to R there is no limit - the 
string you parse+evaluate can be of any length).

Hi Simon,

nuiton-j2r is in fact an abstraction layer to rjava or rserve so that it 
can switch between one or other implementation using simple 
configuration (http://maven-site.nuiton.org/nuiton-j2r/ sorry but this 
is in french). And in fact I encounter the problem using it.


What is done is basically creating the R instruction from java and 
sending it to R using the eval method from the Rengine object (as we use 
jri in this specific application). The R instruction should create an 
object a of class morris, and I try then to get back the a$X object (the 
X item of the morris object) but I get back a null object without any 
reason, that is why I tried copying the instruction directly in R and 
thus getting this problem.


So that is strange if you say that there is no limit using rjava/jri.

Cheers,
Jean


Cheers,
Simon



Duncan Murdoch wrote:

On 01/12/2009 12:50 AM, Jean Couteau wrote:

Thanks for your time Duncan,

I join here the instruction that is not correct, hoping that might 
help you. The file is encoded in utf-8 so you should not have any 
problem reading it.


I doubt to that it is an R bug too, but with all my tests i am less 
and less sure of that.


I have no problem sourcing that file, but I do get an error if I try 
to cut and paste it, because it's a single line of 4890 characters, 
and that's too long.  So this is an R limitation, but it's one with 
an easy workaround:  just add some line breaks into your source.


Duncan Murdoch




Best regards,
Jean Couteau
Your message has encoding problems, so it's not readable.  Could 
you put the code online somewhere where we could download it in 
its original form?  I doubt if this is an R bug, but I can't point 
out the problem in your code (or confirm that it really is an R 
bug) without an undamaged copy of the code.


Duncan Murdoch










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







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


[Rd] ./configure warning (PR#14104)

2009-12-03 Thread thoralf . dassler
Full_Name: 
Version: devel_2009-12-01
OS: Linux
Submission from: (NULL) (146.87.149.164)


Can ./configure be made/told to look in

/usr/share/texmf/bin
instead of
/usr/bin or /usr/local/bin

for pdftex and pdflatex?

This saves me from creating symlinks, which, once there, create issues with
other programmes I am trying to compile.

Thanks

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


[Rd] dchisq tail accuracy (PR#14105)

2009-12-03 Thread Jerry . Lewis
Full_Name: Jerry W. Lewis
Version: 2.10.0
OS: Windows XP Professional
Submission from: (NULL) (198.180.131.16)


dchisq is inaccurate in the extreme tails.  For instance, dchisq(1510,2,952)
returns 4.871004e-18 which is almost 15 times smaller than the correct value of
7.053889e-17.  A better approach for ncp>0 would be
  besselI(sxn,d2,TRUE) * (x/ncp)^(d2/2) * exp(sxn-(x+ncp)/2)/2
where logs may prevent over/underflow in extreme calculations.

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


Re: [Rd] dchisq tail accuracy (PR#14105)

2009-12-03 Thread jerry . lewis
The undefined variables in the original post are
   d2 <- df/2-1
   sxn <- sqrt(x*ncp)

Jerry
[[alternative HTML version deleted]]

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


[Rd] S4 and head() problems

2009-12-03 Thread Robin Hankin

Hi

I am having difficulty defining an S4 method for head() and tail().

I can't quite provide minimal self-contained code
because the problem appears to require the whole corpus
of my package; and there also appears to be a difference
between sourcing the lines directly, and having them
installed in a package.

The lines in question (I think) are:

setClass("mdm",
representation = representation(
  xold  = "matrix",
  types = "factor"
  )
)

"mdm" <- function(xold, types){
 new("mdm", xold=xold, types=types)
}

setGeneric("head",function(x,...){standardGeneric("head")})
setMethod("head",signature="mdm",function(x,n=6,...){
 mdm(head(x...@xold,n=n,...) , types=factor(head(x...@types,n=n,...)))
} )


If the above lines are part of the package source, and I install the package
then sometimes  I get errors like

> head(toy_mm())
Error in function (classes, fdef, mtable)  :
 unable to find an inherited method for function "head", for signature 
"matrix"

>

and sometimes it works as desired.

Why should head() not be able to take the first few lines of a matrix?
It seems to be "forgetting" that head.matrix() exists.

Can anyone give me some pointers for debugging this problem?

rksh







--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

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


Re: [Rd] ./configure warning (PR#14104)

2009-12-03 Thread Prof Brian Ripley
It's odd to have a architecture-specific directory (bin) under a 
no-architecture one (/usr/share).


But why have you filed a question as a bug report?  See the section 
BUGS in the FAQ.


Simply, configure looks along your path for executables, so set the 
path suitably when running configure: it captures the full paths of 
the selected exectuables.  E.g. I have


R_LATEXCMD=${R_LATEXCMD-${LATEX-'/usr/texbin/latex'}}

because I had /usr/texbin in my path when I configured R.


On Wed, 2 Dec 2009, thoralf.dass...@gmail.com wrote:


Full_Name:
Version: devel_2009-12-01
OS: Linux
Submission from: (NULL) (146.87.149.164)


Can ./configure be made/told to look in

/usr/share/texmf/bin
instead of
/usr/bin or /usr/local/bin

for pdftex and pdflatex?

This saves me from creating symlinks, which, once there, create issues with
other programmes I am trying to compile.

Thanks

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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] Bug in R evaluating a huge instruction (PR#14096)

2009-12-03 Thread Romain Francois

Hi,

You really should use the REngine API, which lets you control jri and 
Rserve using the same api. See the org.rosuda.REngine package in 
http://www.rforge.net/org/docs/


Either wayn, I have no problem evaluating the problematic string with 
both apis.


Romain

On 12/02/2009 03:26 PM, Jean Couteau wrote:

FWIW the restriction is only on the console input - if you send it
directly, there is no limit (I have never heard of nuiton-j2r but if
you use rJava to interface from Java to R there is no limit - the
string you parse+evaluate can be of any length).

Hi Simon,

nuiton-j2r is in fact an abstraction layer to rjava or rserve so that it
can switch between one or other implementation using simple
configuration (http://maven-site.nuiton.org/nuiton-j2r/ sorry but this
is in french). And in fact I encounter the problem using it.

What is done is basically creating the R instruction from java and
sending it to R using the eval method from the Rengine object (as we use
jri in this specific application). The R instruction should create an
object a of class morris, and I try then to get back the a$X object (the
X item of the morris object) but I get back a null object without any
reason, that is why I tried copying the instruction directly in R and
thus getting this problem.

So that is strange if you say that there is no limit using rjava/jri.

Cheers,
Jean


Cheers,
Simon



Duncan Murdoch wrote:

On 01/12/2009 12:50 AM, Jean Couteau wrote:

Thanks for your time Duncan,

I join here the instruction that is not correct, hoping that might
help you. The file is encoded in utf-8 so you should not have any
problem reading it.

I doubt to that it is an R bug too, but with all my tests i am less
and less sure of that.


I have no problem sourcing that file, but I do get an error if I try
to cut and paste it, because it's a single line of 4890 characters,
and that's too long. So this is an R limitation, but it's one with
an easy workaround: just add some line breaks into your source.

Duncan Murdoch




Best regards,
Jean Couteau

Your message has encoding problems, so it's not readable. Could
you put the code online somewhere where we could download it in
its original form? I doubt if this is an R bug, but I can't point
out the problem in your code (or confirm that it really is an R
bug) without an undamaged copy of the code.

Duncan Murdoch


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/Gq7i : ohloh
|- http://tr.im/FtUu : new package : highlight
`- http://tr.im/EAD5 : LondonR slides

import org.rosuda.REngine.* ;
import org.rosuda.REngine.JRI.* ;

public class MorrisREngine {

public static void main(String[] args) {
String cmd = "a<-morris(model=NULL,factors=c(\"PecheAmateurs 
décembre.proportionMetier\",\"PechePetitMetierMer 
mai.proportionMetier\",\"PecheAmateurs mai.proportionMetier\",\"PecheChalutiere 
janvier.minInactivityDays\",\"PechePetitMetierEtang 
octobre.minInactivityDays\",\"PechePetitMetierEtang 
décembre.minInactivityDays\",\"FiletMer.standardisationFactor\",\"PecheAmateurs
 juin.minInactivityDays\",\"PechePetitMetierEtang 
novembre.minInactivityDays\",\"PechePetitMetierMer 
septembre.minInactivityDays\",\"PechePetitMetierMer 
avril.minInactivityDays\",\"PecheAmateurs 
août.proportionMetier\",\"PecheChalutiere 
novembre.minInactivityDays\",\"PechePetitMetierMer 
février.proportionMetier\",\"PecheChalutiere 
juillet.minInactivityDays\",\"PechePetitMetierMer 
octobre.proportionMetier\",\"CSar Groupe 
5.reproductionRate\",\"PechePetitMetierMer 
août.proportionMetier\",\"PechePetitMetierMer 
janvier.minInactivityDays\",\"PechePetitMetierEtang 
mai.minInactivityDays\",\"PecheAmateurs 
octobre.minInactivityDays\",\"PecheAmateurs 
septembre.minInactivityDays\",\"PecheChalutiere 
juin.minInactivityDays\",\"PecheChalutiere 
avril.minInactivityDays\",\"PecheAmateurs 
juillet.proportionMetier\",\"PecheChalutiere 
mai.minInactivityDays\",\"PechePetitMetierEtang 
septembre.minInactivityDays\",\"PechePetitMetierMer 
janvier.proportionMetier\",\"PecheAmateurs 
septembre.proportionMetier\",\"PechePetitMetierEtang 
février.minInactivityDays\",\"PechePetitMetierEtang 
mars.minInactivityDays\",\"PechePetitMetierEtang 
juillet.minInactivityDays\",\"PechePetitMetierMer 
septembre.proportionMetier\",\"CSar.capturability\",\"PechePetitMetierMer 
juin.proportionMetier\",\"PecheChalutiere 
mars.minInactivityDays\",\"PecheChalutiere 
septembre.minInactivityDays\",\"PecheAmateurs 
janvier.minInactivityDays\",\"PechePetitMetierMer 
août.minInactivityDays\",\"PechePetitMetierMer 
juillet.proportionMetier\",\"PecheChalutiere 
décembre.minInactivityDays\",\"PecheAmateurs 
avril.minInactivityDays\",\"PecheAmateurs 
mars.proportionMetier\",\"PechePetitMetierMer 
novembre.minInactivityDays\",\"PechePetitMetierEtang 
août.minInactivityDays\",\"CSar.recruitmentDistribution\",\"PecheChalutiere 
février.minInactivityDays\"

Re: [Rd] S4 and head() problems

2009-12-03 Thread Martin Maechler
Hi Robin,

> "Robin" == Robin Hankin 
> on Thu, 03 Dec 2009 11:04:03 + writes:

> Hi
> I am having difficulty defining an S4 method for head() and tail().

> I can't quite provide minimal self-contained code
> because the problem appears to require the whole corpus
> of my package; and there also appears to be a difference
> between sourcing the lines directly, and having them
> installed in a package.

> The lines in question (I think) are:

> setClass("mdm",
> representation = representation(
> xold  = "matrix",
> types = "factor"
> )
> )

> "mdm" <- function(xold, types){
> new("mdm", xold=xold, types=types)
> }

> setGeneric("head",function(x,...){standardGeneric("head")})

I would not use setGeneric() here
rather only setMethod() :

> setMethod("head",signature="mdm",function(x,n=6,...){
> mdm(head(x...@xold,n=n,...) , types=factor(head(x...@types,n=n,...)))
> } )


> If the above lines are part of the package source, and I install the 
package
> then sometimes  I get errors like

>> head(toy_mm())
> Error in function (classes, fdef, mtable)  :
> unable to find an inherited method for function "head", for signature 
> "matrix"
>> 

> and sometimes it works as desired.

> Why should head() not be able to take the first few lines of a matrix?
> It seems to be "forgetting" that head.matrix() exists.

> Can anyone give me some pointers for debugging this problem?

> rksh

you did not mention if your package uses a NAMESPACE
and if yes, what exactly you import and export,
and that can matter quite a bit.

In the Matrix package, we do *not* call setGeneric() for head,
just setMethod(), and I'd advise you to do that too.

Why you get different behavior depending on how exactly you load
the code seems very had to diagnose from a distance.

Regards,
Martin

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


Re: [Rd] boxplot: auto sizing for ylim variable

2009-12-03 Thread violet lock
Sorry, I though I had reposted the question-  I was trying to create a
barplot- I just solved it by looping and setting the program to graph as
subset of the data.  The size is a parameter so the user can reset it if
needed

bargraph <- function(table) {
barplot(table,  main="Title", xlim=c(0,120), horiz=TRUE, las=2)
}
...calc of j and end...
smaller_table=bigtable[j:end]
bargraph(smaller_table)





On Wed, Dec 2, 2009 at 3:02 PM, Greg Snow  wrote:

> I don't understand your question.  Are you trying to create a boxplot or
> barplot (you mention both), what scaling is not happening automatically that
> you would like?
>
> Can you give a simple example of what you have tried, what results you are
> seeing and what results you would like to see instead?
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
> > -Original Message-
> > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-
> > project.org] On Behalf Of violet lock
> > Sent: Tuesday, December 01, 2009 12:34 PM
> > To: r-devel@r-project.org
> > Subject: [Rd] boxplot: auto sizing for ylim variable
> >
> > Dear R-Devel,
> > I am trying to create a boxplot for a large dataset (about 1500
> > entries)
> >  and was wondering if there was away to do auto sizing for the y-axis
> > of a
> > horizontal bar plot?  I know I could use a control structure to loop
> > through
> > the data instead, but as I know SAS has something does this
> > automatically I
> > thought R might as well.
> >
> > Thanks,
> > VL
> >
> >   [[alternative HTML version deleted]]
>  >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

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


[Rd] documentation of intersect() on string vector and num vector and on duplicated elements (PR#14107)

2009-12-03 Thread pengyu . ut
Full_Name: 
Version: 2.10.0
OS: 
Submission from: (NULL) (128.249.106.234)


The document on intersect()'s argument are spread into Arguments and Details
sections (see ?intersect). 

The following description is on the arguments (but from Details section). So I
think that it makes more sense to bring it to the Arguments section. May I
recommend such modification in future releases of R.

"Each of union, intersect, setdiff and setequal will discard any duplicated
values in the arguments, and they apply as.vector to their arguments (and so in
particular coerce factors to character vectors)."

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


[Rd] question about differences in behavior with NA subscripts in matrix vs. data.frame

2009-12-03 Thread Mark Kimpel
I ran into a problem today when using a conditional for sub-setting a
data.frame and tracked it down to a difference in behavior between the
treatment of NA when sub-setting matrices and data.frames. A self-contained
example is below followed by sessionInfo(). I'm not questioning the
documentation of the behavior, but the rationale for its existence.

Could someone explain to me why the difference is logical and useful? This
seems more of a devel than a help issue, my apologies if I've posted to the
incorrect list.

Mark
#
a.vec <- c("A", "", "B", "DEF", NA, "", NA, "Q")
a.vec[a.vec == ""] <- NA
a.vec
## [1] "A"   NA"B"   "DEF" NANANA"Q"

a.mat <- matrix(rep(c("A", "", "B", "DEF", NA, "", NA, "Q"), 5), nrow = 5,
ncol = 8)
a.mat[a.mat[,3] == "", 3] <- NA
a.mat
##  [,1]  [,2] [,3]  [,4]  [,5] [,6]  [,7] [,8]
## [1,] "A"   ""   "B"   "Q"   NA   ""NA   "DEF"
## [2,] ""NA   "DEF" "A"   ""   "B"   "Q"  NA
## [3,] "B"   "Q"  NA""NA   "DEF" "A"  ""
## [4,] "DEF" "A"  NA"B"   "Q"  NA""   NA
## [5,] NA""   NA"DEF" "A"  """B"  "Q"

a.df <- data.frame(matrix(rep(c("A", "", "B", "DEF", NA, "", NA, "Q"), 5),
nrow = 5, ncol = 8))
a.df[a.df[,3] == "", 3] <- NA
a.df
## Error in `[<-.data.frame`(`*tmp*`, a.df[, 3] == "", 3, value = NA) :
##   missing values are not allowed in subscripted assignments of data
frames

## Enter a frame number, or 0 to exit

## 1: `[<-`(`*tmp*`, a.df[, 3] == "", 3, value = NA)
## 2: `[<-.data.frame`(`*tmp*`, a.df[, 3] == "", 3, value = NA)
## remove plain text non-codes from codes.df
sessionInfo()
## R version 2.10.0 Patched (2009-10-27 r50222)
## x86_64-unknown-linux-gnu

## locale:
##  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
##  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
##  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
##  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
##  [9] LC_ADDRESS=C   LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

## attached base packages:
## [1] stats graphics  grDevices datasets  utils methods   base

## loaded via a namespace (and not attached):
## [1] tools_2.10.0
Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 399-1219 Skype No Voicemail please

[[alternative HTML version deleted]]

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


Re: [Rd] group generics

2009-12-03 Thread Martin Morgan
Hi Ross --

Ross Boylan wrote:
> 
> 
> Martin Morgan wrote:
>> Hi Ross -- 
> 
>> Ross Boylan  writes:
> 
>>> I have classes A and B, where B contains A.  In the implementation of
>>> the group generic for B I would like to use the corresponding group
>>> generic for A.  Is there a way to do that?
> 
>>> setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
>>> # the next line does not work right
>>>   v <- selectMethod("callGeneric", signature=c("numeric", "A"))(e1, e2)
>> v <- callGeneric(e1, as(e2, "A"))
> 
>> or probably
> 
>>v <- callNextMethod(e1, e2)
> 
>> Martin
> 
> A different error this time, one that looks a lot like the report from
> stephen.p...@ubs.com on 2007-12-24 concerning callNextMethod:, except
> this is with
> callGeneric.
> 
> HOWEVER, the problem is erratic; when I started from scratch and took
> this code into a workspace and executed the commands, they worked as
> expected.  I had various false starts and revisions, as well as the real
> code on which the example is based, when the error occurred.  I tried
> taking in the real code (which defines generics with Arith from my
> actual classes, and which also fails as below), and the example still
> worked.
> 
> 
> My revised code:
> 
> setClass("A",
>  representation=representation(xa="numeric")
>  )
> 
> setMethod("Arith", signature(e1="numeric", e2="A"), function(e1, e2) {
>   new("A", xa=callGeneric(e1, e...@xa))
> }
>  )
> 
> setClass("B",
>  representation=representation(xb="numeric"),
>  contains=c("A")
>  )
> 
> setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
>   new("B", xb=e1...@xb, callNextMethod())
> }
> )
> 
> Results:
>> options(error=recover)
>> tb <- new("B", xb=1:3, new("A", xa=10))
>> 3*tb
> Error in get(fname, envir = envir) : object '.nextMethod' not found

I feel obliged to respond, since you were following my original
suggestion, but I don't really have a clear answer. I think the error
message is really an issue in the S4 infrastructure, arising from
combining callNextMethod, callGeneric, and group generics; I don't have
further insight on solving the underlying problem, and perhaps I have
misplaced expectations on how these elements are supposed to play
together. A work around is to stick with callGeneric

setClass("A", representation=representation(xa="numeric"))

setMethod("Arith", signature(e1="numeric", e2="A"), function(e1, e2) {
new("A", xa=callGeneric(e1, e...@xa))
})

setClass("B",
 representation=representation(xb="numeric"),
 contains=c("A"))

setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
new("B", xb=e1...@xb, callGeneric(e1, as(e2, "A")))
})

tb <- new("B", xb=1:3, new("A", xa=10)); 3 * tb

Martin

> 
> Enter a frame number, or 0 to exit
> 
>  1: 3 * tb
>  2: 3 * tb
>  3: test.R#16: new("B", xb = e1 * e...@xb, callNextMethod())
>  4: initialize(value, ...)
>  5: initialize(value, ...)
>  6: callNextMethod()
>  7: .nextMethod(e1 = e1, e2 = e2)
>  8: test.R#6: new("A", xa = callGeneric(e1, e...@xa))
>  9: initialize(value, ...)
> 10: initialize(value, ...)
> 11: callGeneric(e1, e...@xa)
> 12: get(fname, envir = envir)
> 
> Selection: 0
> 
> The callGeneric in frame 11 is trying to get the primitive for
> multiplying numeric times numeric.  Quoting from Pope's analysis:
> [The primitive...]
>> does not get the various "magic" variables such as .Generic, .Method,
>> etc. defined in its frame. Thus, callGeneric() fails when, failing to
>> find ".Generic" then takes the function symbol for the call (which
>> callNextMethod() has constructed to be ".nextMethod") and attempts to
>> look it up, which of course also fails, leading to the resulting error
>> seen above.
> 
> I'm baffled, and hoping someone on the list has an idea.
> I'm running R 2.10 under ESS (in particular, I use c-c c-l in the code
> file to read in the code) on XP.

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [Rd] group generics

2009-12-03 Thread Ross Boylan
Thanks for your help.  I had two concerns about using as: that it would
impose some overhead, and that it would require me to code an explicit
conversion function.  I see now that the latter is not true; I don't
know if the overhead makes much difference.

On Thu, 2009-12-03 at 13:00 -0800, Martin Morgan wrote:
> setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
> new("B", xb=e1...@xb, callGeneric(e1, as(e2, "A")))
> })

Things were getting too weird, so I punted and used explicitly named
function calls for the multiplication operation that was causing
trouble.

Ross

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


Re: [Rd] group generics

2009-12-03 Thread John Chambers
I missed the earlier round of this discussion and only am commenting now 
to say that this doesn't seem weird at all, if I understand what you're 
trying to do.

Martin's basic suggestion,

v <- callGeneric(e1, as(e2, "A"))

seems the simplest solution.

You just want to make another call to the actual generic function, with 
new arguments, and let method selection take place.  In fact, it's 
pretty much the standard way to use group generics. 

John


Ross Boylan wrote:
> Thanks for your help.  I had two concerns about using as: that it would
> impose some overhead, and that it would require me to code an explicit
> conversion function.  I see now that the latter is not true; I don't
> know if the overhead makes much difference.
>
> On Thu, 2009-12-03 at 13:00 -0800, Martin Morgan wrote:
>   
>> setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
>> new("B", xb=e1...@xb, callGeneric(e1, as(e2, "A")))
>> })
>> 
>
> Things were getting too weird, so I punted and used explicitly named
> function calls for the multiplication operation that was causing
> trouble.
>
> Ross
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>   

[[alternative HTML version deleted]]

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


Re: [Rd] group generics

2009-12-03 Thread Ross Boylan
On Thu, 2009-12-03 at 14:25 -0800, John Chambers wrote:
> I missed the earlier round of this discussion and only am commenting
> now to say that this doesn't seem weird at all, if I understand what
> you're trying to do.
> 
> Martin's basic suggestion,
> v <- callGeneric(e1, as(e2, "A"))
> seems the simplest solution.
> 
> You just want to make another call to the actual generic function,
> with new arguments, and let method selection take place.  In fact,
> it's pretty much the standard way to use group generics.  
> 
> John
There were 2 weird parts.  Mainly I was referring to the fact that
identical code (posted earlier) worked sometimes and not others.  I
could not figure out what the differences were between the 2 scenarios,
nor could I create a non-working scenario reliably.

The second part that seemed weird was that the code looked as if it
should work all the time (the last full version I posted, which used
callNextMethod() rather than callGeneric()).

Finally, I felt somewhat at sea with the group generics, since I wasn't
sure exactly how they worked, how they interacted with primitives, or
how they interacted with callNextMethod, selectMethod, etc.  I did study
what I thought were the relevant help entries.

Ross
> 
> 
> Ross Boylan wrote: 
> > Thanks for your help.  I had two concerns about using as: that it would
> > impose some overhead, and that it would require me to code an explicit
> > conversion function.  I see now that the latter is not true; I don't
> > know if the overhead makes much difference.
> > 
> > On Thu, 2009-12-03 at 13:00 -0800, Martin Morgan wrote:
> >   
> > > setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
> > > new("B", xb=e1...@xb, callGeneric(e1, as(e2, "A")))
> > > })
> > > 
> > 
> > Things were getting too weird, so I punted and used explicitly named
> > function calls for the multiplication operation that was causing
> > trouble.
> > 
> > Ross
> > 
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> > 
> >

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


[Rd] Error in namespaceExport(ns, exports) :

2009-12-03 Thread David Scherrer
Dear all,

I get the error

"Error in namespaceExport(ns, exports) :
  undefined exports function1 , function2"

when compiling or even when I roxygen my package. The two function I once
had in my package but I deleted them including their .Rd files. I also can't
find them in any other function or help file.

So does anybody know where these functions are still listed that causes this
error?

Many thanks,
David

[[alternative HTML version deleted]]

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


[Rd] Error read.table()'s help page and put the distinction between (PR#14109)

2009-12-03 Thread pengyu . ut
The word 'be' is missing after 'will' in the following sentence from
?read.table.

"Note that in either case the columns will logical unless =91colClasses=92
was supplied."

Another suggestion:

I think that it is make more sense to put at the begining the
description of the difference between the methods listed in on the
help page of read.table.

Currently, the document put the description of the arguments at the
beginning. But a new user would first want to figure out which method
to use before knowing what the arguments are.

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


Re: [Rd] Tabs in R source code

2009-12-03 Thread Peng Yu
On Sun, Nov 29, 2009 at 11:18 AM, Duncan Murdoch  wrote:
> On 29/11/2009 11:50 AM, Peng Yu wrote:
>>
>> On Sun, Nov 29, 2009 at 10:40 AM, Duncan Murdoch 
>> wrote:
>>>
>>> On 29/11/2009 10:58 AM, Peng Yu wrote:

 Some lines are indented by tabs and some lines are indented by spaces,
 in R source code. This might due to the fact that the source code is
 not from a single person. But I think that it is better to enforce a
 single convention.

 My editor defaults a tab to 8 spaces. So some source doesn't seem to
 be indented correctly in my editor. Since tab may be displayed
 differently in different editor, I recommend to replace all the tabs
 by the appropriate number of spaces to ensure the same indentation
 display.
>>>
>>> The R source code assumes that tabs occur every 8 columns, so if your
>>> editor
>>> is working properly, it should display files as intended.
>>>
 Could somebody update the source code in the future version by
 replacing tabs by spaces and enforce such a coding convention in the
 future?
>>>
>>> No, that would not be feasible, for the reason you give in the second
>>> sentence of your post.
>>
>> I don't understand why it is not feasible. The spaces are displayed
>> the same in all editors. If there are no tabs, the code should display
>> the same in all editors. I know some languages that are recommended to
>> have spaces rather than tabs for this reason.
>
> It is not feasible because it would require everyone who edits the source
> code to change the configuration of their editors.  In my case, that would
> require changing about 3 different types of editors (I work on several
> different platforms).  I would probably miss one, and re-introduce tabs the
> next time I edited a file on that editor.

http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html

Here is the R style, which does not recommend using tabs. Although it
might take some time to forbidden the use of tabs, it will eventually
be a good practice that benefits everyone in the future.

> I've already seen problems in the NEWS and CHANGES files, which have
> recently changed to UTF-8 encoding.  It's very irritating that my editor
> switches back to the Windows default if it doesn't see a byte-order mark,
> and that some editors that I use automatically delete the BOM. Requiring a
> particular "encoding" for tabs (i.e. converting them to spaces) would lead
> to the same problems, but on a much bigger scale.
>
> Duncan Murdoch
>

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


Re: [Rd] Tabs in R source code

2009-12-03 Thread Sharpie


pengyu.ut wrote:
> 
> http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
> 
> Here is the R style, which does not recommend using tabs. Although it
> might take some time to forbidden the use of tabs, it will eventually
> be a good practice that benefits everyone in the future.
> 

Whoa, put the kibosh on that thought. 

That is Google's style guide for R code written at Google by Google
employees.  It is by no means the style guide adopted by the R core team. 
Representing it as the "official" R style guide is just inviting a torrent
of flaming email.

-- 
View this message in context: 
http://n4.nabble.com/Tabs-in-R-source-code-tp930751p948240.html
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