[R] RODBC compile error with R 2.4.1

2007-01-03 Thread Matthew Dowle

Hi All,

I'm getting the following error,  could anyone help please?

$ R CMD INSTALL RODBC_1.1-7.tar.gz
* Installing *source* package 'RODBC' ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sql.h usability... yes
checking sql.h presence... yes
checking for sql.h... yes
checking sqlext.h usability... yes
checking sqlext.h presence... yes
checking for sqlext.h... yes
checking for library containing SQLTables... -lodbc
checking for SQLLEN... yes
checking for SQLULEN... yes
checking for long... yes
checking size of long... configure: error: cannot compute sizeof (long),
77
See `config.log' for more details.
ERROR: configuration failed for package 'RODBC'
** Removing '/usr/local/lib/R/library/RODBC'
** Restoring previous '/usr/local/lib/R/library/RODBC'

 version
   _   
platform   x86_64-unknown-linux-gnu
arch   x86_64  
os linux-gnu   
system x86_64, linux-gnu   
status 
major  2   
minor  4.1 
year   2006
month  12  
day18  
svn rev40228   
language   R   
version.string R version 2.4.1 (2006-12-18)



Regards,
Matthew

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] FW: Debug package question

2006-10-23 Thread Matthew Dowle

Dear list,

I received the response below from the package author of 'debug'.  I
post it to the list, with Mark's approval, in case it is useful to
others too.

Regards, Matthew


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 22 October 2006 23:53
To: Matthew Dowle
Cc: [EMAIL PROTECTED]
Subject: RE: Debug package question


Hi Matthew

That's an interesting point. If it's your own code, my recommendation
would be to predefine the function and then mtrace it, as you suggest.
But I can see that this isn't always easy, e.g. if you're trying to
debug a system function.

Because every little operation in R is actually a function call, it's
probably not very useful for 'mtrace' to have a step-into mode. [Anyway,
whether useful or not, it doesn't have one! ;)] 

The simplest way to get what you're after-- but it might not work--
would be to 'mtrace(apply)' and then call 'mtrace( FUN)' manually when
the debug window for 'apply' appears. The snag is that 'apply' is quite
likely to feature somewhere in the workings of 'debug' (I can't
remember!) so you might hang the thing altogether. Also, if your own
function happens to call 'apply' (directly or indirectly) you will get
stuck with a lot of debug windows.

A more robust, complicated, and devious way to get what you're after, is
to write a version of 'apply' that automatically calls 'mtrace' on its
function-argument and then invokes the real 'apply'. Something like
this:

mtrace.apply - function( X, MARGIN, FUN, ...) {
  FFF - FUN # don't know whether this is necessary
  mtrace( FFF) # naughty-- should really arrange for name to be unique
  mc - match.call( expand.dots=TRUE)
  mc$FUN - FFF
  mc[[1]] - quote( apply)
  eval( mc, envir=parent.frame())
}

Then call 'mtrace.apply' instead of 'apply'.

BTW: if your pass-in function isn't crashing the first time it's called,
you might find it useful to use the 'bp(1,F)' trick the first time it
appears in a debug window-- this means that it won't pop the window up
and wait for input until/unless there's a crash.

Hope this helps-- and glad you like the package

Mark

Mark Bravington
CSIRO Mathematical  Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623
 

 -Original Message-
 From: Matthew Dowle [mailto:[EMAIL PROTECTED]
 Sent: Friday, 20 October 2006 8:20 PM
 To: Bravington, Mark (CMIS, Hobart)
 Subject: Debug package question
 
 
  Hi Mark,
  
  I've been using your excellent debug for a while now.  Its truly
  excellent.
  
  The most common reason I find it useful is when R returns
 subscript
  out of bounds error.  R provides no context information in the
  message so I just mtrace() the function and your package 
 tells me the
  line straight away.  Perfect.
  
  I have one question ... when I use the apply() family to apply a
  function and the error occurs inside the function *defined* 
 inside the
  function,  e.g. :
  
  X = matrix(...)
  apply(X, 2, function(x) {
   lots of lines 
  ... M[m,] ...
   lots of lines 
  ... N[n,] ...
   lots of lines 
  ... O[o,] ...
   lots of lines 
  })
  
  Where it is the M[m,],  N[n,] or O[o,]  which generates the out of
  bounds on a particular iteration,  but you don't know which one.
  
  Mtrace() will skip over the apply() and say the same as R,
 that an out
  of bounds has occurred somewhere, but not where,  since
 mtrace has not
  been called on the function(x).
  
  One way to work around this, is to define the sub-function
 first with
  a name,   call mtace() on it,  then execute the apply.
 Is that the
  only way?   Is there a way to set mtrace() to automatically mtrace()
  any function it calls,  like step into and step over in other
  languages ?
  
  Regards,
  Matthew
  
  
   version
   _  
  platform i386-pc-mingw32
  arch i386   
  os   mingw32
  system   i386, mingw32  
  status  
  major2  
  minor1.1
  year 2005   
  month06 
  day  20 
  language R  
   
  
  and also
  
   version
   _   
  platform x86_64-unknown-linux-gnu
  arch x86_64  
  os   linux-gnu   
  system   x86_64, linux-gnu   
  status   
  major2   
  minor1.1 
  year 2005
  month06  
  day  20  
  language R   
   
  
  
 


__
R-help@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
and provide commented, minimal, self-contained, reproducible

[R] Avoiding a memory copy by [[

2006-05-23 Thread Matthew Dowle

Hi,

n = 1000
L = list(a=integer(n), b=integer(n))

L[[2]][1:10]  gives me the first 10 items of the 2nd vector in the list L.
It works fine.  However it appears to copy the entire L[[2]] vector in
memory first, before subsetting it.  It seems reasonable that [[ can't
know that all that is to be done is to do [1:10] on the result and therefore
a copy in memory of the entire vector L[[2]] is not required.  Only a new
vector length 10 need be created.  I see why [[ needs to make a copy in
general.

L[[c(2,1)]]  gives me the 1st item of the 2nd vector in the list L.  It
works fine,  and does not appear to copy L[[2]] in memory first.  Its much
faster as n grows large.

But I need more than 1 element of the vector   L[[c(2,1:10)]]   fails
with Error: recursive indexing failed at level 2

Is there a way I can obtain the first 10 items of L[[2]] without a memory
copy of L[[2]]  ?

Thanks!
Matthew

R 2.1.1


[[alternative HTML version deleted]]

__
R-help@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


Re: [R] Avoiding a memory copy by [[

2006-05-23 Thread Matthew Dowle

Thanks.

I looked some more and found that L$b[1:10] doesn't seem to copy L$b.  If
that's correct why does L[[2]][1:10] copy L[[2]] ?

 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: 23 May 2006 16:23
 To: Matthew Dowle
 Cc: 'r-help@stat.math.ethz.ch'
 Subject: Re: [R] Avoiding a memory copy by [[
 
 
 On Tue, 23 May 2006, Matthew Dowle wrote:
 
 
  Hi,
 
  n = 1000
  L = list(a=integer(n), b=integer(n))
 
  L[[2]][1:10]  gives me the first 10 items of the 2nd vector in the 
  list L. It works fine.  However it appears to copy the 
 entire L[[2]] 
  vector in memory first, before subsetting it.  It seems reasonable 
  that [[ can't know that all that is to be done is to do [1:10] on 
  the result and therefore a copy in memory of the entire 
 vector L[[2]] 
  is not required.  Only a new vector length 10 need be 
 created.  I see 
  why [[ needs to make a copy in general.
 
  L[[c(2,1)]]  gives me the 1st item of the 2nd vector in the 
 list L.  
  It works fine,  and does not appear to copy L[[2]] in 
 memory first.  
  Its much faster as n grows large.
 
  But I need more than 1 element of the vector   
 L[[c(2,1:10)]]   fails
  with Error: recursive indexing failed at level 2
 
 Note that [[ ]] is documented to only ever return one 
 element, so this is 
 invalid.
 
  Is there a way I can obtain the first 10 items of L[[2]] without a 
  memory copy of L[[2]]  ?
 
 Use .Call
 
 -- 
 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-help@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


Re: [R] Avoiding a memory copy by [[

2006-05-23 Thread Matthew Dowle

That development sounds excellent. I'm happy to help test it, just let me
know.

Until 2.4.0 then I'll do something like the following, because I need to
deal with list integer locations rather than names :

eval(parse(text=paste(L$',names(L)[2],'[1:10],sep=)))

This works well but if there is an easier way until 2.4.0, please let me
know.

Thank you and Henrik for your replies.


 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: 23 May 2006 17:47
 To: Henrik Bengtsson
 Cc: Matthew Dowle; r-help@stat.math.ethz.ch
 Subject: Re: [R] Avoiding a memory copy by [[
 
 
 On Tue, 23 May 2006, Henrik Bengtsson wrote:
 
  On 5/23/06, Matthew Dowle [EMAIL PROTECTED] wrote:
  
  Thanks.
  
  I looked some more and found that L$b[1:10] doesn't seem 
 to copy L$b.  
  If that's correct why does L[[2]][1:10] copy L[[2]] ?
 
  I forgot, this is probably what I was told in discussion about
  UseMethod($) the other day: The $ operator is very special. Its 
  second argument (the one after the operator) is not evaluated.  For 
  [[ it is.  This is probably also why the solution with 
 environment 
  works.  I think some with the more knowledge about the R 
 core has to 
  give you the details on this, and especially why $ is 
 special in the 
  first place (maybe because of the example you're giving).
 
 That's not the reason here: the internal code for [[ 
 duplicates for vector 
 lists but not pairlists.  That could be replaced by a NAMED 
 optimization, 
 although we would not do that until 2.4.0 (for which Thomas 
 Lumley has 
 written profiling code for memory use and duplication).
 
 
  /Henrik
 
   -Original Message-
   From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
   Sent: 23 May 2006 16:23
   To: Matthew Dowle
   Cc: 'r-help@stat.math.ethz.ch'
   Subject: Re: [R] Avoiding a memory copy by [[
  
  
   On Tue, 23 May 2006, Matthew Dowle wrote:
  
   
Hi,
   
n = 1000
L = list(a=integer(n), b=integer(n))
   
L[[2]][1:10]  gives me the first 10 items of the 2nd vector in 
the list L. It works fine.  However it appears to copy the
   entire L[[2]]
vector in memory first, before subsetting it.  It seems 
reasonable that [[ can't know that all that is to be 
 done is to 
do [1:10] on the result and therefore a copy in memory of the 
entire
   vector L[[2]]
is not required.  Only a new vector length 10 need be
   created.  I see
why [[ needs to make a copy in general.
   
L[[c(2,1)]]  gives me the 1st item of the 2nd vector in the
   list L.
It works fine,  and does not appear to copy L[[2]] in
   memory first.
Its much faster as n grows large.
   
But I need more than 1 element of the vector 
   L[[c(2,1:10)]]   fails
with Error: recursive indexing failed at level 2
  
   Note that [[ ]] is documented to only ever return one 
 element, so 
   this is invalid.
  
Is there a way I can obtain the first 10 items of 
 L[[2]] without 
a memory copy of L[[2]]  ?
  
   Use .Call
  
   --
   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-help@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
  
  
 
 
 
 -- 
 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-help@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


[R] a+b

2006-05-02 Thread Matthew Dowle

Hi,

Is there a way to define + so that a+b returns ab ?

 setMethod(+,c(character,character),paste)
Error in setMethod(+, c(character, character), paste) : 
the method for function '+' and signature e1=character,
e2=character is sealed and cannot be re-defined
 a+b
Error in a + b : non-numeric argument to binary operator

Thanks!



[[alternative HTML version deleted]]

__
R-help@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


Re: [R] a+b

2006-05-02 Thread Matthew Dowle

Thanks for the information.  By 'not easily' it sounds like it is possible,
but how?  I'm happy to allow 'errors' like 2+3=23, is that what an
erroneous use could be?

I tried the following, given the info in your reply, which works.  But is
there a way to allow a+b=ab?
 x = a
 `+.character` - function(e1, e2) paste(e1,e2, sep=)
 attr(x,class)=character
 x+x
[1] aa


 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: 02 May 2006 12:03
 To: Matthew Dowle
 Cc: 'r-help@stat.math.ethz.ch'
 Subject: Re: [R] a+b
 
 
 Not easily.  There's a comment in ?Ops that for efficiency the group 
 generics only dispatch on objects with a class attribute: 
 otherwise you 
 could use an S3 method like
 
 `+.character` - function(e1, e2) paste(e1,e2, sep=)
 
 S4 methods are built on top of S3 methods as far as internal 
 dispatch is 
 concerned, so the same comment will apply there AFAICS.
 
 I would think that the intention was also to positively 
 discourage messing 
 with the basics of R, as if you were able to do this 
 erroneous uses would 
 likely not get caught.
 
 On Tue, 2 May 2006, Matthew Dowle wrote:
 
 
  Hi,
 
  Is there a way to define + so that a+b returns ab ?
 
  setMethod(+,c(character,character),paste)
  Error in setMethod(+, c(character, character), paste) :
 the method for function '+' and signature e1=character, 
  e2=character is sealed and cannot be re-defined
  a+b
  Error in a + b : non-numeric argument to binary operator
 
  Thanks!
 
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@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
 
 
 -- 
 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-help@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


Re: [R] a+b

2006-05-02 Thread Matthew Dowle

Ok, thanks for clarifying.

 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: 02 May 2006 12:51
 To: Matthew Dowle
 Cc: 'r-help@stat.math.ethz.ch'
 Subject: RE: [R] a+b
 
 
 On Tue, 2 May 2006, Matthew Dowle wrote:
 
  Thanks for the information.  By 'not easily' it sounds like it is 
  possible, but how?
 
 Change the C code.  R is Open Source, so anything is possible.
 
  I'm happy to allow 'errors' like 2+3=23, is that what an 
  erroneous use could be?
 
 2 + x, for example, where x is not numeric.
 
  I tried the following, given the info in your reply, which 
 works.  But 
  is there a way to allow a+b=ab?
  x = a
  `+.character` - function(e1, e2) paste(e1,e2, sep=) 
  attr(x,class)=character
  x+x
  [1] aa
 
 
  -Original Message-
  From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
  Sent: 02 May 2006 12:03
  To: Matthew Dowle
  Cc: 'r-help@stat.math.ethz.ch'
  Subject: Re: [R] a+b
 
 
  Not easily.  There's a comment in ?Ops that for efficiency 
 the group 
  generics only dispatch on objects with a class 
 attribute: otherwise 
  you could use an S3 method like
 
  `+.character` - function(e1, e2) paste(e1,e2, sep=)
 
  S4 methods are built on top of S3 methods as far as 
 internal dispatch 
  is concerned, so the same comment will apply there AFAICS.
 
  I would think that the intention was also to positively discourage 
  messing with the basics of R, as if you were able to do this
  erroneous uses would
  likely not get caught.
 
  On Tue, 2 May 2006, Matthew Dowle wrote:
 
 
  Hi,
 
  Is there a way to define + so that a+b returns ab ?
 
  setMethod(+,c(character,character),paste)
  Error in setMethod(+, c(character, character), paste) :
 the method for function '+' and signature e1=character, 
  e2=character is sealed and cannot be re-defined
  a+b
  Error in a + b : non-numeric argument to binary operator
 
  Thanks!
 
 
 
[[alternative HTML version deleted]]
 
  __
  R-help@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
 
 
  --
  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
 
 
 
 
 -- 
 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-help@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


Re: [R] a+b

2006-05-02 Thread Matthew Dowle

Perfect. Thank you!

 -Original Message-
 From: Martin Morgan [mailto:[EMAIL PROTECTED] 
 Sent: 02 May 2006 17:10
 To: Matthew Dowle
 Cc: 'Prof Brian Ripley'; 'r-help@/usr/bin/idn: 
 idna_to_ascii_4z() failed with error 3. 
 r-help@stat.math.ethz.ch@fhcrc.org
 Subject: Re: [R] a+b
 
 
 I think %any-symbol% defines a binary operator, so
 
  %+% - function(x,y) paste(x,y,sep=)
  a %+% b
 [1] ab
  
 
 or for more fun
 
  setGeneric(%+%, function(x,y) standardGeneric(%+%))
 [1] %+%
  setMethod(%+%, signature(x=character, y=character), 
  function(x,y) paste(x,y,sep=))
 [1] %+%
  setMethod(%+%, signature(x=numeric, y=numeric), function(x,y) 
  x+y)
 [1] %+%
  a %+% b
 [1] ab
  1 %+% 2
 [1] 3
  
 
 Martin
 
 Matthew Dowle [EMAIL PROTECTED] writes:
 
  Thanks for the information.  By 'not easily' it sounds like it is 
  possible, but how?  I'm happy to allow 'errors' like 
 2+3=23, is 
  that what an erroneous use could be?
 
  I tried the following, given the info in your reply, which 
 works.  But 
  is there a way to allow a+b=ab?
  x = a
  `+.character` - function(e1, e2) paste(e1,e2, sep=) 
  attr(x,class)=character
  x+x
  [1] aa
 
 
  -Original Message-
  From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
  Sent: 02 May 2006 12:03
  To: Matthew Dowle
  Cc: 'r-help@stat.math.ethz.ch'
  Subject: Re: [R] a+b
  
  
  Not easily.  There's a comment in ?Ops that for efficiency 
 the group
  generics only dispatch on objects with a class attribute: 
  otherwise you 
  could use an S3 method like
  
  `+.character` - function(e1, e2) paste(e1,e2, sep=)
  
  S4 methods are built on top of S3 methods as far as internal
  dispatch is 
  concerned, so the same comment will apply there AFAICS.
  
  I would think that the intention was also to positively
  discourage messing 
  with the basics of R, as if you were able to do this 
  erroneous uses would 
  likely not get caught.
  
  On Tue, 2 May 2006, Matthew Dowle wrote:
  
  
   Hi,
  
   Is there a way to define + so that a+b returns ab ?
  
   setMethod(+,c(character,character),paste)
   Error in setMethod(+, c(character, character), paste) :
  the method for function '+' and signature e1=character,
   e2=character is sealed and cannot be re-defined
   a+b
   Error in a + b : non-numeric argument to binary operator
  
   Thanks!
  
  
  
[[alternative HTML version deleted]]
  
   __
   R-help@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
  
  
  -- 
  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-help@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


__
R-help@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


Re: [R] Function dependency function

2006-04-03 Thread Matthew Dowle

That is amazing.

foodweb(prune=myfunct) does precisely what I described. It even draws a
graph!

Hats off to the author Mark Bravington.

Thanks Erik for the pointer.

Regards, Matthew


 -Original Message-
 From: Erik Iverson [mailto:[EMAIL PROTECTED] 
 Sent: 31 March 2006 17:21
 To: Matthew Dowle
 Cc: 'r-help@stat.math.ethz.ch'
 Subject: Re: [R] Function dependency function
 
 
 I had a similar need and found package mvbutils, function foodweb().
 
  From the help file:
 
   'foodweb' is applied to a group of functions (e.g. all those in a
   workspace); it produces a graphical display showing the 
 hierarchy
   of which functions call which other ones. This is handy, for
   instance, when you have a great morass of functions in a
   workspace, and want to figure out which ones are meant to be
   called directly. 'callers.of(funs)' and 'callees.of(funs)' show
   which functions directly call, or are called directly 
 by, 'funs'.
 
 Hope that helps,
 Erik Iverson
 
 Matthew Dowle wrote:
  Hi,
  
  Is there a function taking a function as an argument, which returns 
  all the functions it calls, and all the the functions those 
 functions call, and so
  on?I could use Rprof, but that would involve executing 
 the function,
  which may miss some branches of code.   I'd really like a 
 function which
  looks at the source code to work out all the functions that 
 could possibly
  be called.   When I develop a function and release to 
 production environment
  (or to some library) then I may need to release other 
 functions I've 
  developed which that function calls.  As soon as the function call 
  stack goes outside .GlobalEnv (for example into base) then 
 the search 
  can stop as I'm only interested in functions in .GlobalEnv  (my own 
  functions).  Also useful would be the reverse function  
 i.e.  find all 
  functions which could possibly call the function.  This 
 could be used 
  to find functions which are never called and could be 
 considered for 
  deletion.
  
  Thanks,
  Matthew
  
  
  
  [[alternative HTML version deleted]]
  
  __
  R-help@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


__
R-help@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


[R] Function dependency function

2006-03-31 Thread Matthew Dowle

Hi,

Is there a function taking a function as an argument, which returns all the
functions it calls, and all the the functions those functions call, and so
on?I could use Rprof, but that would involve executing the function,
which may miss some branches of code.   I'd really like a function which
looks at the source code to work out all the functions that could possibly
be called.   When I develop a function and release to production environment
(or to some library) then I may need to release other functions I've
developed which that function calls.  As soon as the function call stack
goes outside .GlobalEnv (for example into base) then the search can stop as
I'm only interested in functions in .GlobalEnv  (my own functions).  Also
useful would be the reverse function  i.e.  find all functions which could
possibly call the function.  This could be used to find functions which are
never called and could be considered for deletion.

Thanks,
Matthew



[[alternative HTML version deleted]]

__
R-help@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


[R] Deparsing '...'

2006-03-02 Thread Matthew Dowle

Hi,

The following function works, but is there a neater way to write it?

f = function(x,...)
{
# return a character vector of the arguments passed in after 'x'
gsub(
,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] 
}

 f(x,a,b,c*d)
[1] a   b   c*d
 

Thanks.



[[alternative HTML version deleted]]

__
R-help@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


Re: [R] Deparsing '...'

2006-03-02 Thread Matthew Dowle

That's much neater, thanks.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
 Behalf Of Peter Dalgaard
 Sent: 02 March 2006 16:59
 To: Matthew Dowle
 Cc: 'r-help@stat.math.ethz.ch'
 Subject: Re: [R] Deparsing '...'
 
 
 Matthew Dowle [EMAIL PROTECTED] writes:
 
  Hi,
  
  The following function works, but is there a neater way to write it?
  
  f = function(x,...)
  {
  # return a character vector of the arguments passed in after 'x'
  gsub( 
  ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1]
  }
  
   f(x,a,b,c*d)
  [1] a   b   c*d
   
 
 
  f - function(x,...)as.character(match.call(expand.dots=FALSE)$...)
   f(x,a,b,c*d)
 [1] a b c * d
 
 or maybe
 
 f  - function(x,...)
   sapply(match.call(expand.dots=FALSE)$..., deparse, backtick=TRUE)
 
 
 
 
 -- 
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  
 (+45) 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: 
 (+45) 35327907


__
R-help@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


Re: [R] Deparsing '...'

2006-03-02 Thread Matthew Dowle

That's even neater.  But when its called from within another function, this
happens, see below.  I was planning to call f something like 'getdots' and
use it in several functions that need to do this.

 f - function(...) as.character(match.call())[-1]
 f(a,b,c)
[1] a b c
 g = function(x,...) f(...)
 g(x,a,b,c)
[1] ..1 ..2 ..3


 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: 02 March 2006 17:18
 To: Matthew Dowle
 Cc: 'r-help@stat.math.ethz.ch'
 Subject: Re: [R] Deparsing '...'
 
 
 f - function(...) as.character(match.call())[-1]
  f(x,a,b,c*d)
 [1] x a b c * d
 
 On Thu, 2 Mar 2006, Matthew Dowle wrote:
 
 
  Hi,
 
  The following function works, but is there a neater way to write it?
 
  f = function(x,...)
  {
 # return a character vector of the arguments passed in after 'x'
 gsub( 
  ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1]
  }
 
  f(x,a,b,c*d)
  [1] a   b   c*d
 
 
  Thanks.
 
 -- 
 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-help@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


Re: [R] Deparsing '...'

2006-03-02 Thread Matthew Dowle

That works well. So the final version is:
getdots = function() as.character(match.call(sys.function(-1),
call=sys.call(-1), expand.dots=FALSE)$...)

Thank you both for your help.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
 Behalf Of Peter Dalgaard
 Sent: 02 March 2006 18:07
 To: Matthew Dowle
 Cc: 'Prof Brian Ripley'; 'r-help@stat.math.ethz.ch'
 Subject: Re: [R] Deparsing '...'
 
 
 Matthew Dowle [EMAIL PROTECTED] writes:
 
  That's even neater.  But when its called from within 
 another function, 
  this happens, see below.  I was planning to call f something like 
  'getdots' and use it in several functions that need to do this.
  
   f - function(...) as.character(match.call())[-1]
   f(a,b,c)
  [1] a b c
   g = function(x,...) f(...)
   g(x,a,b,c)
  [1] ..1 ..2 ..3
 
 Yes, that will (and must) happen. If you really want to go 
 that route, you need something in the veins of
 
  f - function() match.call(sys.function(-1), call=sys.call(-1)) g = 
  function(x,...) f()
  g(x,a,b,c)
 g(x = x, a, b, c)
 
  
   -Original Message-
   From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
   Sent: 02 March 2006 17:18
   To: Matthew Dowle
   Cc: 'r-help@stat.math.ethz.ch'
   Subject: Re: [R] Deparsing '...'
   
   
   f - function(...) as.character(match.call())[-1]
f(x,a,b,c*d)
   [1] x a b c * d
   
   On Thu, 2 Mar 2006, Matthew Dowle wrote:
   
   
Hi,
   
The following function works, but is there a neater way 
 to write 
it?
   
f = function(x,...)
{
   # return a character vector of the arguments passed 
 in after 'x'
   gsub(

 ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1]
}
   
f(x,a,b,c*d)
[1] a   b   c*d
   
   
Thanks.
   
   -- 
   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-help@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
  
 
 -- 
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  
 (+45) 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: 
 (+45) 35327907
 


__
R-help@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


Re: [R] data.frame() size

2005-12-09 Thread Matthew Dowle

That explains it. Thanks. I don't need rownames though, as I'll only ever
use integer subscripts. Is there anyway to drop them, or even better not
create them in the first place? The memory saved (90%) by not having them
and 10 times speed up would be very useful. I think I need a data.frame
rather than a matrix because I have columns of different types in real life.

 rownames(d) = NULL
Error in dimnames-.data.frame(`*tmp*`, value = list(NULL, c(a, b : 
invalid 'dimnames' given for data frame


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter
Dalgaard
Sent: 08 December 2005 18:57
To: Matthew Dowle
Cc: 'r-help@stat.math.ethz.ch'
Subject: Re: [R] data.frame() size


Matthew Dowle [EMAIL PROTECTED] writes:

 Hi,
 
 In the example below why is d 10 times bigger than m, according to 
 object.size ? It also takes around 10 times as long to create, which 
 fits with object.size() being truthful.  gcinfo(TRUE) also indicates a 
 great deal more garbage collector activity caused by data.frame() than 
 matrix().
 
 $ R --vanilla
 
  nr = 100
  system.time(m-matrix(integer(1), nrow=nr, ncol=2))
 [1] 0.22 0.01 0.23 0.00 0.00
  system.time(d-data.frame(a=integer(nr), b=integer(nr)))
 [1] 2.81 0.20 3.01 0.00 0.00  # 10 times longer
 
  dim(m)
 [1] 100   2
  dim(d)
 [1] 100   2   # same dimensions
 
  storage.mode(m)
 [1] integer
  sapply(d, storage.mode)
 a b 
 integer integer   # same storage.mode
 
  object.size(m)/1024^2
 [1] 7.629616
  object.size(d)/1024^2
 [1] 76.29482  # but 10 times bigger
 
  sum(sapply(d, object.size))/1024^2
 [1] 7.629501  # or is it ?If its not
 really 10 times bigger, why 10 times longer above ?

Row names!!


 r - as.character(1:1e6)
 object.size(r)
[1] 7256
 object.size(r)/1024^2
[1] 68.6646

'nuff said?

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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


[R] data.frame() size

2005-12-08 Thread Matthew Dowle

Hi,

In the example below why is d 10 times bigger than m, according to
object.size ? It also takes around 10 times as long to create, which fits
with object.size() being truthful.  gcinfo(TRUE) also indicates a great deal
more garbage collector activity caused by data.frame() than matrix().

$ R --vanilla

 nr = 100
 system.time(m-matrix(integer(1), nrow=nr, ncol=2))
[1] 0.22 0.01 0.23 0.00 0.00
 system.time(d-data.frame(a=integer(nr), b=integer(nr)))
[1] 2.81 0.20 3.01 0.00 0.00# 10 times longer

 dim(m)
[1] 100   2
 dim(d)
[1] 100   2 # same dimensions

 storage.mode(m)
[1] integer
 sapply(d, storage.mode)
a b 
integer integer # same storage.mode

 object.size(m)/1024^2
[1] 7.629616
 object.size(d)/1024^2
[1] 76.29482# but 10 times bigger

 sum(sapply(d, object.size))/1024^2
[1] 7.629501# or is it ?If its not
really 10 times bigger, why 10 times longer above ?

 version
platform x86_64-unknown-linux-gnu
arch x86_64  
os   linux-gnu   
system   x86_64, linux-gnu   
status   
major2   
minor1.1 
year 2005
month06  
day  20  
language R   


Many thanks in advance!
Matthew



[[alternative HTML version deleted]]

__
R-help@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


[R] tapply huge speed difference if X has names

2005-08-08 Thread Matthew Dowle

Hi all,

Apologies if this has been raised before ... R's tapply is very fast, but if
X has names in this example, there seems to be a huge slow down: under 1
second compared to 151 seconds.  The following timings are repeatable and
are timed properly on a single user machine :

 X = 1:10
 names(X) = X
 system.time(fast-tapply(as.vector(X), rep(1:1,each=10), mean))  #
as.vector() to drop the names
[1] 0.36 0.00 0.35 0.00 0.00
 system.time(slow-tapply(X, rep(1:1,each=10), mean))
[1] 149.95   1.83 151.79   0.00   0.00
 head(fast)
   123456 
 5.5 15.5 25.5 35.5 45.5 55.5 
 head(slow)
   123456 
 5.5 15.5 25.5 35.5 45.5 55.5 
 identical(fast,slow)
[1] TRUE
 

Looking inside tapply, which then calls split, it seems there is an
is.null(names(x)) which prevents R's internal fast version from being
called. Why is that there? Could it be removed?  I often do something like
tapply(mat[,colname],...) where mat has rownames. Therefore the rownames
of mat become the names of the vector mat[,colname], and this seems to
slow down tapply a lot. Perhaps other functions which call split also suffer
this problem?

 split.default
function (x, f)
{
if (is.list(f)) 
f - interaction(f)
f - factor(f)
if (is.null(attr(x, class))  is.null(names(x))) 
return(.Internal(split(x, f)))
lf - levels(f)
y - vector(list, length(lf))
names(y) - lf
for (k in lf) y[[k]] - x[f %in% k]
y
}
environment: namespace:base
 

 version
 _  
platform x86_64-redhat-linux-gnu
arch x86_64 
os   linux-gnu  
system   x86_64, linux-gnu  
status  
major2  
minor0.1
year 2004   
month11 
day  15 
language R  
 


Thanks and regards,
Matthew



[[alternative HTML version deleted]]

__
R-help@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


[R] Problem with filter() ?

2005-07-08 Thread Matthew Dowle

Dear list,

This is ok :

 filter(1:5, 1, recursive)
Time Series:
Start = 1 
End = 5 
Frequency = 1 
[1]  1  3  6 10 15

But this? :

 filter(c(rep(NA,5),1:5), 1, recursive)
Time Series:
Start = 1 
End = 10 
Frequency = 1 
 [1] NA  0 NA  0 NA  0  2  5  9 14
 

 version
 _  
platform x86_64-redhat-linux-gnu
arch x86_64 
os   linux-gnu  
system   x86_64, linux-gnu  
status  
major2  
minor0.1
year 2004   
month11 
day  15 
language R  
 

Regards,
Matthew

__
R-help@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


RE: [R] Tcl error - brace in argument?

2004-11-29 Thread Matthew Dowle

Peter,

Yes c(0,23) works.

Many thanks!
Matthew


-Original Message-
From: Peter Dalgaard [mailto:[EMAIL PROTECTED] 
Sent: 26 November 2004 16:43
To: Peter Dalgaard
Cc: Matthew Dowle; '[EMAIL PROTECTED]'
Subject: Re: [R] Tcl error - brace in argument?


Peter Dalgaard [EMAIL PROTECTED] writes:

 Matthew Dowle [EMAIL PROTECTED] writes:
 
  Hi all,
   
  Does anyone know a solution for this error ?
   
   tkwidget(dlg, iwidgets::spinint, range={0 23})
 
 I suspect you want range=as.tclObj(c(0,23)) or something like that, 
 i.e. a Tcl list of two numbers, not a five-character string.

On second thoughts: I think range=c(0,23) should do.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Tcl error - brace in argument?

2004-11-26 Thread Matthew Dowle
Hi all,
 
Does anyone know a solution for this error ?
 
 tkwidget(dlg, iwidgets::spinint, range={0 23})
 
Error in structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class =
tclObj) : 
[tcl] wrong # args: should be .31.1.19 configure -range {begin
end}.

Thanks,
Matthew
 
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RDCOMClient under R2.0.0 - not a valid package

2004-10-19 Thread Matthew Dowle

Dear r-help,

Both '[EMAIL PROTECTED]' and '[EMAIL PROTECTED]' appear
to be bouncing with 'user unknown' so trying r-help 
[ Btw, mailing lists link on omega page is returning mailman CGI error.
]

  require(RDCOMClient)
 Loading required package: RDCOMClient 
 Error in library(package, character.only = TRUE, logical = TRUE,
 warn.conflicts = warn.conflicts,  : 
 'RDCOMClient' is not a valid package -- installed  2.0.0?
  version
  _  
 platform i386-pc-mingw32
 arch i386   
 os   mingw32
 system   i386, mingw32  
 status   beta   
 major2  
 minor0.0
 year 2004   
 month09 
 day  28 
 language R  
  
 
 I have re-installed RDCOMClient_0.8-1.zip under R2.0.0 but still getting
 the error above.   Any ideas/suggestions much appreciated.  The file
 ../library/RDCOMClient/Meta/package.rds appears to be missing?
 
 Regards,
 Matthew
 
 
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RExcel : problem with error handler?

2004-10-06 Thread Matthew Dowle

Dear R-help,

Call RInterface.StartRServer  ' Works fine
Call RInterface.RRun(objects())   ' Works fine
Call Rinterface.RRun( other R commands which do not generate errors, the
demos etc )   ' Works fine
But ...
Call RInterface.RRun(doesnotexist)' Sends Excel into endless loop it
appears

After about 90 seconds a dialog box appears  Microsoft Excel is waiting for
another application to complete an OLE action.  Click OK then it hangs for
another minute or so, and displays the dialogue again. Task manager is
required to kill Excel.  I rebooted to ensure only Excel is running, so
there should be no conflicts with any other app, but the same error is
repeatable. In this case I was expecting the R error Object doesnotexist
not found be passed back into Excel, either as a dialogue box in Excel, or
available to VBA using a GetRError function or something?

I hope someone can help, or point me in the right direction.

Info from About RExcel :

RExcel version 1.35
RDCOM server 1.35
R system software: Version 2.0.0
Microsoft Excel 10.0
Windows NT 5.01

 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status   beta   
major2  
minor0.0
year 2004   
month09 
day  28 
language R  
 

Many thanks,
Matthew





[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] is.weekend() odd behaviour

2004-05-26 Thread Matthew Dowle

It seems is.weekend() is unsure ?

# Start R 1.9.0 with --vanilla on windows xp
# load package chron

 table(is.weekend(sapply(1:100, function(i){Sys.sleep(0.05);Sys.time()})))
FALSE  TRUE 
   6832 
 date()
[1] Wed May 26 11:18:56 2004

 version _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor9.0
year 2004   
month04 
day  12 
language R  
 


[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] is.weekend() odd behaviour

2004-05-26 Thread Matthew Dowle

Thanks. When is.weekend() is given an object it doesn't know about, could a
warning or error be added? At the moment, I think you're agreeing, that it
silently returns a random TRUE/FALSE.

-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: 26 May 2004 11:55
To: Matthew Dowle
Cc: '[EMAIL PROTECTED]'
Subject: Re: [R] is.weekend() odd behaviour


Matthew Dowle wrote:

 It seems is.weekend() is unsure ?

It is completely sure, if an object is given is.weekend() knows about as in:

table(is.weekend(sapply(1:100, 
function(i){Sys.sleep(0.05);as.chron(Sys.time())})))

(note the as.chron() call!)

Uwe Ligges



 # Start R 1.9.0 with --vanilla on windows xp
 # load package chron
 
 
table(is.weekend(sapply(1:100, 
function(i){Sys.sleep(0.05);Sys.time()})))
 
 FALSE  TRUE 
6832 
 
date()
 
 [1] Wed May 26 11:18:56 2004
 
 
version _  
 
 platform i386-pc-mingw32
 arch i386   
 os   mingw32
 system   i386, mingw32  
 status  
 major1  
 minor9.0
 year 2004   
 month04 
 day  12 
 language R  
 
 
 
   [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


FW: [R] is.weekend() odd behaviour

2004-05-26 Thread Matthew Dowle

Kurt,

Uwe suggested I write to you as maintainer of chron ... at the start of
is.weekend, in the check on the argument type, maybe just change chron() to
as.chron()? This would ensure as.chron.POSIXt gets called on POSIXt
arguments, and (I think) fixes the problem. I tested and it seems ok. No
warning/error required.

 is.weekend
function(x)
{
if(!inherits(x, dates))
if(is.character(x) || is.numeric(x))
x - as.chron(x)   # was  x - chron(x)
else stop(x must inherit from dates)

}

-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: 26 May 2004 13:20
To: Matthew Dowle
Cc: '[EMAIL PROTECTED]'
Subject: Re: [R] is.weekend() odd behaviour


Matthew Dowle wrote:

 Thanks. When is.weekend() is given an object it doesn't know about, 
 could a warning or error be added? At the moment, I think you're 
 agreeing, that it silently returns a random TRUE/FALSE.

It's not random, it depends on the value of Sys.time(), which also 
includes seconds .
I agree that a warning or error might be sensible. So I think you are 
about to write a note to the maintainer of package chron including 
patches for is.weekend() and friends?

Uwe Ligges





 -Original Message-
 From: Uwe Ligges [mailto:[EMAIL PROTECTED]
 Sent: 26 May 2004 11:55
 To: Matthew Dowle
 Cc: '[EMAIL PROTECTED]'
 Subject: Re: [R] is.weekend() odd behaviour
 
 
 Matthew Dowle wrote:
 
 
It seems is.weekend() is unsure ?
 
 
 It is completely sure, if an object is given is.weekend() knows about 
 as in:
 
 table(is.weekend(sapply(1:100,
 function(i){Sys.sleep(0.05);as.chron(Sys.time())})))
 
 (note the as.chron() call!)
 
 Uwe Ligges
 
 
 
 
# Start R 1.9.0 with --vanilla on windows xp
# load package chron



table(is.weekend(sapply(1:100,
function(i){Sys.sleep(0.05);Sys.time()})))

FALSE  TRUE 
   6832 


date()

[1] Wed May 26 11:18:56 2004



version _  

platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor9.0
year 2004   
month04 
day  12 
language R  



  [[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RODBC MS SQL Server: repeated calls to sqlGetResults() problem

2004-04-30 Thread Matthew Dowle

Dear list,

RODBC is mostly working very well on Windows XP talking to MS SQL Server.
However, when trying to retrieve a result set in repeated batches the first
batch returns results ok, but then subsequent calls return no data (see code
below). I tried setting believeNRows=FALSE both in odbcConnect() and in
sqlGetResults() but this doesn't appear to make any difference. Also
odbcFetchRows() suffers the same problem.  The documentation states
sqlGetResults is a mid-level function. It should be called after a call to
odbcQuery and used to retrieve waiting results into a data frame. Its main
use is with max set to non zero it will retrieve the result set in batches
with repeated calls.

Have I mis-understood? Is this a driver problem? Something else?  Any
help/advice much appreciated.

Many thanks in advance,

Matthew


 channel = odbcConnect(MY DSN)
 odbcGetInfo(channel)
[1] Microsoft SQL Server version 08.00.0760. Driver ODBC version 03.52
 odbcQuery(channel, select * from TEST)# Table TEST contains a single
column by 100 rows
[1] 1
 sqlGetResults(channel, max=10)
  last_update
1  2004-02-06
2  2004-02-06
3  2004-02-06
4  2004-02-06
5  2004-02-06
6  2004-02-06
7  2004-02-06
8  2004-02-06
9  2004-02-06
10 2004-02-06
 sqlGetResults(channel, max=10)
[1] last_update
0 rows (or 0-length row.names)# why is this empty?
 
 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor9.0
year 2004   
month04 
day  12 
language R  


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html