[Rd] Arithmetic bug? (found when use POSIXct) (PR#10776)

2008-02-16 Thread gmail
Full_Name: Bo Zhou
Version: 2.6.1 (2007-11-26)
OS: Windows XP
Submission from: (NULL) (207.237.54.242)


Hi,

I found an arithmetic problem when I'm doing something with POSIXct
The code to reproduce it is as follows (This is the recommended way of finding
out time zone difference on R News 2004-1 Page 32 URL
http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf)

a=Sys.time()
b<-as.POSIXct(format(a,tz="GMT"))
a-b
unclass(a)
unclass(b)
unclass(a)-unclass(b)
as.numeric(a)
as.numeric(b)
as.numeric(a)-as.numeric(b)

The result on my machine

> a=Sys.time()
> b<-as.POSIXct(format(a,tz="GMT"))
> a-b
Time difference of -4.69 hours
> unclass(a)
[1] 1203184447
> unclass(b)
[1] 1203202447
attr(,"tzone")
[1] ""
> unclass(a)-unclass(b)
[1] -17999.89
attr(,"tzone")
[1] ""
> as.numeric(a)
[1] 1203184447
> as.numeric(b)
[1] 1203202447
> as.numeric(a)-as.numeric(b)
[1] -17999.89
>

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


Re: [Rd] Arithmetic bug? (found when use POSIXct) (PR#10776)

2008-02-16 Thread Gabor Grothendieck
See FAQ 7.31 or explain what you believe to be the problem.

On Feb 16, 2008 1:05 PM,  <[EMAIL PROTECTED]> wrote:
> Full_Name: Bo Zhou
> Version: 2.6.1 (2007-11-26)
> OS: Windows XP
> Submission from: (NULL) (207.237.54.242)
>
>
> Hi,
>
> I found an arithmetic problem when I'm doing something with POSIXct
> The code to reproduce it is as follows (This is the recommended way of finding
> out time zone difference on R News 2004-1 Page 32 URL
> http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf)
>
> a=Sys.time()
> b<-as.POSIXct(format(a,tz="GMT"))
> a-b
> unclass(a)
> unclass(b)
> unclass(a)-unclass(b)
> as.numeric(a)
> as.numeric(b)
> as.numeric(a)-as.numeric(b)
>
> The result on my machine
>
> > a=Sys.time()
> > b<-as.POSIXct(format(a,tz="GMT"))
> > a-b
> Time difference of -4.69 hours
> > unclass(a)
> [1] 1203184447
> > unclass(b)
> [1] 1203202447
> attr(,"tzone")
> [1] ""
> > unclass(a)-unclass(b)
> [1] -17999.89
> attr(,"tzone")
> [1] ""
> > as.numeric(a)
> [1] 1203184447
> > as.numeric(b)
> [1] 1203202447
> > as.numeric(a)-as.numeric(b)
> [1] -17999.89

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


Re: [Rd] forcing gc() to do its work

2008-02-16 Thread Duncan Murdoch
On 16/02/2008 7:56 PM, Vadim Organovich wrote:
> Hi,
> 
> At some points of my computations I want gc() to try really hard and collect 
> as many objects as possible even though the triggering limits are not hit. 
> Will it help if I temporarily set the limits to some small values, call gc() 
> and then reset them back to their original values? What variables exactly 
> need to be set?  Does anyone have a prototype of such function?
> 
> I tried to read the R help, e.g. Memory and memory.limits(), but I am not 
> sure I understand how this applies to my case.

See the R Internals manual, or the comments in memory.c.  Calling gc() 
makes it try as hard as it can (a level 2 collection).  You can't make 
it try harder.

Duncan Murdoch

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


[Rd] forcing gc() to do its work

2008-02-16 Thread Vadim Organovich
Hi,

At some points of my computations I want gc() to try really hard and collect as 
many objects as possible even though the triggering limits are not hit. Will it 
help if I temporarily set the limits to some small values, call gc() and then 
reset them back to their original values? What variables exactly need to be 
set?  Does anyone have a prototype of such function?

I tried to read the R help, e.g. Memory and memory.limits(), but I am not sure 
I understand how this applies to my case.

Thanks,
Vadim

[[alternative HTML version deleted]]

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


Re: [Rd] choose incorrect for fractional and some negative integer values (PR#10766)

2008-02-16 Thread Ben Bolker
  biogenidec.com> writes:

> 
> Full_Name: Jerry W. Lewis
> Version: 2.6.2
> OS: Windows XP Professional
> Submission from: (NULL) (198.180.131.16)
> 
> choose() returns incorrect values for all fractional arguments, regardless of
> sign.  It returns 0 when both arguments are negative integers, which is not
> always correct (as in some formulations of the negative hypergeometric).
> 
> Examples (correct answers from Maple's binomial function):
> 
> choose( 4.75,2.75)  # should be 8.90625

  [snip]

  The help page does say that k is supposed to be an integer -- so
I don't think this is a bug.
  Should the function either (a) test for k == (or close to ==) an integer
or (b) be rewritten to work more generally?

  Ben

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


[Rd] Probable bug in "An Introduction to R" (PR#10777)

2008-02-16 Thread lefevrol
Both the document and R itself are at 2.6.2 (2008-02-08). When I run in 
the Windows R console the command 

   lines(density(eruptions, bw=0.1))

found in § 8.2, I get:

   Error in plot.xy(xy.coords(x, y), type = type, ...) : 
   plot.new has not been called yet

Regards,

Olivier Lefevre

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


Re: [Rd] Probable bug in "An Introduction to R" (PR#10777)

2008-02-16 Thread ripley
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--27464147-1806382895-1203228439=:29265
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT

You can't just pick out lines and expect them to run on their own.  The 
context is

# make the bins smaller, make a plot of density
hist(eruptions, seq(1.6, 5.2, 0.2), prob=TRUE)
lines(density(eruptions, bw=0.1))
rug(eruptions) # show the actual data points

We do arrange to run the code from that manual to test every release.
And that block of lines does work.


On Sun, 17 Feb 2008, [EMAIL PROTECTED] wrote:

> Both the document and R itself are at 2.6.2 (2008-02-08). When I run in
> the Windows R console the command
>
>   lines(density(eruptions, bw=0.1))
>
> found in § 8.2, I get:
>
>   Error in plot.xy(xy.coords(x, y), type = type, ...) :
>   plot.new has not been called yet
>
> Regards,
>
> Olivier Lefevre
>
> __
> 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
--27464147-1806382895-1203228439=:29265--

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