[Rd] Speed of for loops

2007-01-30 Thread Tom McCallum
Hi Everyone, I have a question about for loops. If you have something like: f <- function(x) { y <- rep(NA,10); for( i in 1:10 ) { if ( i > 3 ) { if ( is.na(y[i-3]) == FALSE ) { # some calculation F which dep

Re: [Rd] Speed of for loops

2007-01-31 Thread Tom McCallum
dify the function for the bookkeeping required to >> manage whatever lag you need. I use this sometimes when I'm >> implementing MCMC samplers of various kinds. >> >> >> On 1/30/07, Herve Pages <[EMAIL PROTECTED]> wrote: >>> Tom McCallum wrote:

[Rd] Best Practise

2007-05-14 Thread Tom McCallum
Hello, Just a quick question on best practise. I am converting quite a bit of legacy C code into R packages and have the following situation: (1) Legacy object with a double* array in, all over code so don't want to change any more than I have to. (2) Do something like: SEXP arrayT

[Rd] DataTime field when converting between database formats

2008-03-03 Thread Tom McCallum
I was recently converting a MS-Access database to MySQL when I came across this error: Error in fromchar(unclass(x)) : character string is not in a standard unambiguous format The error occurs because the NULL value of a DateTime field, if not properly setup or on export to a CSV, can be s

[Rd] RODBC Close Memory Leak Question

2008-07-10 Thread Tom McCallum
Hi everyone, In relation to the RODBC odbcClose bug which was fixed back in the changelog below: Version: 1.2-3 (2008-01-24, released) * Plug a memory leak in inRODBCClose (closing a connection), reported by Stephan Henne. * Use translateChar() on character data sent

[Rd] RODBC Seg Fault

2008-07-14 Thread Tom McCallum
Hi Everyone, At the end of this email is a transcript of a problem I have found in RODBC version 2.3-1. It appears that the bug fix in odbcClose for the memory leak has meant that the garbage collector is falling over when it tries to free up the extPtr attribute of the RODBC connection po

[Rd] Memory problems with a custom R package

2006-09-12 Thread Tom McCallum
Hi everyone, I have been attempting to build a very simple R package interfacing with some very simple C++ code. Everything I try though results in the function working but on return it produces a memory error. Here is the output: ***OUTPUT*** > library(My

[Rd] time_t handling in R

2006-09-27 Thread Tom McCallum
Hello all, I am converting some C code into a package for R and wondered what the proper way of handling time_t types from C in R was. time_t is a typedef for long, but R seems to only deal in Integers or Reals, so what is the proper way of handling time in an R to C conversion ( or visa ve

[Rd] Cross-compilation

2006-10-25 Thread Tom McCallum
machine, having completed all the previous sections of the tutorial for building a cross-platform version of R. Many thanks Tom -- --- Tom McCallum WWW: http://www.tom-mccallum.com Tel: 0131-4783393 Mobile: 07866-470257 __ R-devel@r-project.org mai

Re: [Rd] Cross-compilation

2006-10-25 Thread Tom McCallum
86. I never had to do > anything, just run the script and at least in one case I did > crosscompile a > package with C++. > > > R. > > On Wednesday 25 October 2006 18:03, Tom McCallum wrote: >> Hi everyone, >> >> I am trying to cross-compile a package I wrote

[Rd] Overloading functions

2006-10-27 Thread Tom McCallum
and call f( newGsource="newg.R" ) but I still get "Original function g". Any suggestions? Tom -- --- Tom McCallum WWW: http://www.tom-mccallum.com Tel: 0131-4783393 Mobile: 07866-470257 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] Overloading functions

2006-10-27 Thread Tom McCallum
On Fri, 27 Oct 2006 14:49:15 +0100, Paul Roebuck <[EMAIL PROTECTED]> wrote: > On Fri, 27 Oct 2006, Tom McCallum wrote: > >> I have a function f which does something using a function g. Function f >> is in a library and g has a default stub in the library but will be

Re: [Rd] Overloading functions

2006-10-27 Thread Tom McCallum
On Fri, 27 Oct 2006 15:54:40 +0100, Tom McCallum <[EMAIL PROTECTED]> wrote: > On Fri, 27 Oct 2006 14:49:15 +0100, Paul Roebuck <[EMAIL PROTECTED]> > wrote: > >> On Fri, 27 Oct 2006, Tom McCallum wrote: >> >>> I have a function f which does something us

[Rd] variable problem

2006-11-07 Thread Tom McCallum
Hi everyone, I am not sure this is possible so I would be interested in your responses. Say I have a variable 'v' with the string "myargument" in and I have a function 'f' that takes this argument as follows; f <- function( myargument=5 ) { ... does something... } Is there anyway I can s

Re: [Rd] variable problem

2006-11-07 Thread Tom McCallum
Works like a charm - thank you very much. Tom On Tue, 07 Nov 2006 20:45:04 -, Vladimir Dergachev <[EMAIL PROTECTED]> wrote: > On Tuesday 07 November 2006 3:28 pm, Tom McCallum wrote: >> Hi everyone, > > Hi Tom, > > Would this snippet work: > > fo

[Rd] Retrieving function name

2006-11-09 Thread Tom McCallum
Hi, Does anyone know how I can retrieve a function name, for example If I have a function f as follows: f <- function( myfunc ) { print( name_of(myfunc) ); } I want to know what I should have as "name_of" such that I could call this with : f( median ) and it would print "media

[Rd] String to list and visa versa

2006-11-14 Thread Tom McCallum
Hi, I need to collapse a list into a string and then reparse it back into the list. Normally when I need to do this I simply use write.csv and read.csv, but I need to do this in memory within R rather than writing out to file. Are there any bespoke commands that any knows of that does so

Re: [Rd] String to list and visa versa

2006-11-15 Thread Tom McCallum
On Wed, 15 Nov 2006 05:00:28 -, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Tue, 14 Nov 2006, Vladimir Dergachev wrote: > >> On Tuesday 14 November 2006 12:28 pm, Prof Brian Ripley wrote: >>> This approach won't work in very many cases (but then nor will >>> write.csv). >>> >>> The s

[Rd] Manipulating R lists in C

2006-11-17 Thread Tom McCallum
Hi, I have been studying the R manual on lists but cannot seem to create a simple R list in C - I keep on getting "'dimnames' applied to non-array" whenever I attempt to assign names to the list elements: Wanted output a list structure something like [ type="Bid", price=2.0, volume=10

Re: [Rd] Manipulating R lists in C

2006-11-17 Thread Tom McCallum
Thank you so much!! - that works now. Tom On Fri, 17 Nov 2006 14:40:38 -, Roger Bivand <[EMAIL PROTECTED]> wrote: > On Fri, 17 Nov 2006, Tom McCallum wrote: > >> Hi, >> >> I have been studying the R manual on lists but cannot seem to create a >> si

[Rd] Data table in C

2006-11-17 Thread Tom McCallum
After getting one list done, I am now struggling to form a data frame in C. I tried to do a list of lists which gives me : $ $[[1]] [1] "BID" $[[2]] [1] 0.6718 $[[3]] [1] 3e+06 $ $[[1]] [1] "BID" $[[2]] [1] 0.6717 $[[3]] [1] 5e+06 $ $[[1]] [1] "BID" $[[2]] [1] 0.6717 $[[3]] [1] 1720

Re: [Rd] dyn.load

2006-11-22 Thread Tom McCallum
:56 -, Tom McCallum <[EMAIL PROTECTED]> wrote: > Hi everyone, > > Now I know there is information on this in the help files - which I have > read. I am very close to implementing this but can't quite get how to > remove this final hurdle. > > I have a DL

[Rd] Ralloc clash

2006-11-22 Thread Tom McCallum
Hi everyone, Have been trying to include windows.h (from MinGW) and R.h into a package and have found that Ralloc is coming up as a clash no matter which include ordering I use. In windows it has 2 arguments and is defined in objidl.h and in R.h it is 3 arguments. Any ideas of how to work

Re: [Rd] Ralloc clash

2006-11-23 Thread Tom McCallum
u know about defining WIN32_LEAN_AND_MEAN when including > windows.h? If not, it is worth finding out about. > > > On Wed, 22 Nov 2006, Tom McCallum wrote: > >> Hi everyone, >> >> Have been trying to include windows.h (from MinGW) and R.h into a >&g

Re: [Rd] Ralloc clash

2006-11-23 Thread Tom McCallum
This *is* documented in 'Writing R Extensions'. > > On Thu, 23 Nov 2006, Tom McCallum wrote: > >> Thank you for your reply. My mistake - I meant Realloc (missed the >> 'e'). >> This morning I reinstalled MinGW with all the patches suggested by the >

Re: [Rd] Ralloc clash

2006-11-23 Thread Tom McCallum
documented in 'Writing R Extensions'. > > That was the general intention, but seems not to cover this example. > Howver, > > #include > #undef Realloc > #define R_Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (size_t)((n) > * sizeof(t)) ) > #include >

[Rd] Floating point maths in R

2006-12-09 Thread Tom McCallum
Hi, I am not sure if this is just me using R (R-2.3.1 and R-2.4.0) in the wrong way or if there is a more serious bug. I was having problems getting some calculations to add up so I ran the following tests: > (2.34567 - 2.0) == 0.34567 <--- should be true [1] FALSE > (2.23-2.00) == 0

Re: [Rd] Floating point maths in R

2006-12-09 Thread Tom McCallum
Many thanks for pointing that out. Tom On Sat, 09 Dec 2006 13:48:06 -, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Tom McCallum wrote: >> Hi, >> >> I am not sure if this is just me using R (R-2.3.1 and R-2.4.0) in the >> wrong way or if there is