Re: [Rd] histogram method for S4 class.

2005-08-26 Thread Martin Maechler
> "Ernesto" == Ernesto Jardim <[EMAIL PROTECTED]>
> on Fri, 26 Aug 2005 10:15:01 +0100 writes:

Ernesto> Deepayan Sarkar wrote:

>> [I'm CC-ing to r-devel, please post follow-ups there]

>> .

>> Deepayan

Ernesto> ...

Ernesto> ps: I'm not a subscriber of r-devel so I guess I'm
Ernesto> not able to post there, 

yes, you can post here without being a subscriber (the same as with R-help) !

Ernesto> anyway I'm CC-ing there too.

{ the idea was that you'd only send this to R-devel, not to
  R-help as well, once Deepayan has diverted it to here }

BTW: I think you *should* rather subscribe to R-devel, if you
  are an R package writer. 
  We (R-core) actually sometimes behave as if R-devel was
  read by all interested R package writers - even though we know
  it's not quite true.

  Since R-devel has much a smaller bandwidth than R-help, and
  you're already willing to read R-help, why don't you subscribe
  to R-devel?


Regards,
Martin Maechler, ETH Zurich

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


Re: [Rd] histogram method for S4 class.

2005-08-26 Thread Ernesto Jardim
Deepayan Sarkar wrote:

>On 8/24/05, ernesto <[EMAIL PROTECTED]> wrote:
>  
>
>>Hi,
>>
>>I'm trying to develop an histogram method for a class called "FLQuant"
>>which is used by the package FLCore (http://flr-project.org). FLQuant is
>>an extension to "array". There is an as.data.frame method that coerces
>>flquant into a data.frame suitable for lattice plotting. The problem is
>>that when I coerce the object and plot it after it works but if the
>>method is applied within the histogram method it does not work. See the
>>code below (the FLCore package is here
>>http://prdownloads.sourceforge.net/flr/FLCore_1.0-1.tar.gz?download)
>>
>>
>>
>>>library(FLCore)
>>>  
>>>
>>Loading required package: lattice
>>
>>
>>>data(ple4)
>>>histogram(~data|year, [EMAIL PROTECTED])
>>>  
>>>
>>Error in inherits(x, "factor") : Object "x" not found
>>
>>
>>>histogram(~data|year, data=as.data.frame([EMAIL PROTECTED]))
>>>  
>>>
>>The catch.n slot is a FLQuant object and the code for histogram is the
>>following
>>
>>setMethod("histogram", signature(formula="formula", data="FLQuant"),
>>function (formula, data = parent.frame(), allow.multiple =
>>is.null(groups) || outer,
>>outer = FALSE, auto.key = FALSE, aspect = "fill", panel =
>>"panel.histogram", prepanel = NULL,
>>scales = list(), strip = TRUE, groups = NULL, xlab, xlim, ylab,
>>ylim,
>>type = c("percent", "count", "density"),
>>nint = if (is.factor(x)) length(levels(x)) else
>>round(log2(length(x)) + 1),
>>endpoints = extend.limits(range(x[!is.na(x)]), prop = 0.04),
>>breaks = if (is.factor(x)) seq(0.5, length = length(levels(x)) +
>>1) else do.breaks(endpoints, nint),
>>equal.widths = TRUE, drop.unused.levels =
>>lattice.getOption("drop.unused.levels"), ...,
>>default.scales = list(), subscripts = !is.null(groups), subset =
>>TRUE) {
>>
>>qdf <- as.data.frame(data)
>>
>>histogram(formula, data = qdf, allow.multiple = allow.multiple,
>>outer = outer,
>>auto.key = auto.key, aspect = aspect, panel = panel,
>>prepanel = prepanel, scales = scales,
>>strip = strip, groups = groups, xlab=xlab, xlim=xlim,
>>ylab=ylab, ylim=ylim, type = type,
>>nint = nint, endpoints = endpoints, breaks = breaks,
>>equal.widths = equal.widths,
>>drop.unused.levels = drop.unused.levels, ..., default.scales
>>= default.scales,
>>subscripts = subscripts, subset = subset)
>>}
>>)
>>
>>
>>Any ideas ?
>>
>>
>
>[I'm CC-ing to r-devel, please post follow-ups there]
>
>What version of lattice are you using? Please use the latest one, in
>which histogram is an S3 generic, with only one argument, formula. The
>eventual solution to your problem may involve changing that, but the
>first question to ask is whether any other formula makes sense in your
>context (if not, I would rather keep one argument and dispatch on
>signature(formula = "FLQuant").
>
>Disclaimer: I haven't actually had time to check out FLCore yet, I
>will as soon as I can.
>
>Deepayan
>  
>
Hi,

I've installed the version that is distributed with R-2.1.1, 0.11-8. I 
see there's a new version now so I'll install it and check the results. 
I've developed the code a little more using the approach you use for 
dotplot (see below) and I know where the problem is now. I'm not able to 
pass the argument nint, breaks and endpoints to the function call. I 
guess the problem is my programming skils :-(

Thanks

EJ

ps: I'm not a subscriber of r-devel so I guess I'm not able to post 
there, anyway I'm CC-ing there too.



setMethod("histogram", signature(formula="formula", data="FLQuant"), 
function (formula, data = parent.frame(), allow.multiple = 
is.null(groups) || outer, outer = FALSE, auto.key = FALSE, aspect = 
"fill", panel = "panel.histogram", prepanel = NULL, scales = list(), 
strip = TRUE, groups = NULL, xlab, xlim, ylab, ylim, type = c("percent", 
"count", "density"), nint = if (is.factor(x)) length(levels(x)) else 
round(log2(length(x)) + 1), endpoints = 
extend.limits(range(x[!is.na(x)]), prop = 0.04), breaks = if 
(is.factor(x)) seq(0.5, length = length(levels(x)) + 1) else 
do.breaks(endpoints, nint), equal.widths = TRUE, drop.unused.levels = 
lattice.getOption("drop.unused.levels"), ..., default.scales = list(), 
subscripts = !is.null(groups), subset = TRUE) {

# need to develop further, at the moment is not possible to control 
nint, breaks and endpoints.

data <- as.data.frame(data)

dots <- list(...)

groups <- eval(substitute(groups), data, parent.frame())
subset <- eval(substitute(subset), data, parent.frame())

call.list <- c(list(formula = formula, data = data, groups = groups, 
subset = subset, allow.multiple = allow.multiple, outer = outer, 
auto.key = auto.key, aspect = aspect, panel = panel, prepanel = 
prepanel, scales = scales, strip = strip, type = type, equal.widths = 
equal.widths, drop.unused.levels = drop.unused.levels, default.scales = 
defaul

[Rd] Fortran (Was: Re: [R] linux compile options (64-bit))

2005-08-26 Thread Göran Broström
On Tue, Aug 02, 2005 at 12:12:08PM +0200, Göran Broström wrote:
> On Tue, Aug 02, 2005 at 10:58:31AM +0100, Prof Brian Ripley wrote:
> 
> > The problems we are seeing with gcc4 are mainly (but not 
> > entirely) with gfortran: it seems not quite ready for production use.
> > -4.0.1 is already a considerable improvement over -4.0.0.
> > 
> > There is another project (www.g95.org) that is using a slightly different 
> > version of these sources, and either g95 or gfortran can be used with 
> > gcc3 if you want to use F95 sources.  However, F95 is unlikely to be 
> > suitable for use in distributed R packages for a long time to come.
> 
> Thanks; I'll stick to 3.4.4(!) and f77 for the time being.

One short follow-up question on the F77/95 theme: In my CRAN packages, I use
the construct "do while ... end do" in my fortran sources. This is AFAIK not
strict F77, but an extension in g77, and standard in F95. "-pedantic" does not 
complain about this; on the other hand "---it finds some non-ANSI
practices, but not all" (from 'man g77').

Should I rewrite the "do while...end do" parts? (Please answer NO!:)


Göran

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


Re: [Rd] Fortran (Was: Re: [R] linux compile options (64-bit))

2005-08-26 Thread Prof Brian Ripley

On Fri, 26 Aug 2005, Göran Broström wrote:


On Tue, Aug 02, 2005 at 12:12:08PM +0200, Göran Broström wrote:

On Tue, Aug 02, 2005 at 10:58:31AM +0100, Prof Brian Ripley wrote:


The problems we are seeing with gcc4 are mainly (but not
entirely) with gfortran: it seems not quite ready for production use.
-4.0.1 is already a considerable improvement over -4.0.0.

There is another project (www.g95.org) that is using a slightly different
version of these sources, and either g95 or gfortran can be used with
gcc3 if you want to use F95 sources.  However, F95 is unlikely to be
suitable for use in distributed R packages for a long time to come.


Thanks; I'll stick to 3.4.4(!) and f77 for the time being.


One short follow-up question on the F77/95 theme: In my CRAN packages, I use
the construct "do while ... end do" in my fortran sources. This is AFAIK not
strict F77, but an extension in g77, and standard in F95. "-pedantic" does not
complain about this; on the other hand "---it finds some non-ANSI
practices, but not all" (from 'man g77').

Should I rewrite the "do while...end do" parts? (Please answer NO!:)


There are compilers that do not accept that construct: AFAIR the Solaris 
f77 is one.  But, if no one is complaining I would leave it.  (We would 
not allow such things in base R, as inevitably it will cause problems on 
some rare platform.)


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


[Rd] Free-form to fixed-form Fortran

2005-08-26 Thread Aleš Žiberna
Hello!

I have writen some subrutines in Free-form Fortran. I would like to includ 
them in a package, which I would like to build on WinXP. I have all 
suggested tools/programs for bulding R packages on Windows (except latex).

What is the best way of using these subrutines? Does sombody mybe know any 
translation tools for converting Free-form to fixed-form Fortran?

Thanks for any suggestions,
Ales Ziberna

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


Re: [Rd] Functions with the same name: best practices

2005-08-26 Thread hadley wickham
Thanks to all of you for your advice. I will read up on namespaces and
start using them to "protect" my internal function from name clashes
with other packages, and endeavour to my public functions unique
names.

I know other languages (eg. python) separate loading a package and
including it in the default namespace, do you think R will ever move
to such a system?

Thanks,

Hadley

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


Re: [Rd] Functions with the same name: best practices

2005-08-26 Thread Prof Brian Ripley
On Fri, 26 Aug 2005, hadley wickham wrote:

> Thanks to all of you for your advice. I will read up on namespaces and
> start using them to "protect" my internal function from name clashes
> with other packages, and endeavour to my public functions unique
> names.
>
> I know other languages (eg. python) separate loading a package and
> including it in the default namespace, do you think R will ever move
> to such a system?

I don't follow the terminology here, but in R you can load a namespace 
without making the exports visible, which sounds like what you are asking. 
In R `loading a package' means making its objects visible from the 
top-level scope.

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

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


[Rd] Memory leakage/violation?

2005-08-26 Thread Henrik Bengtsson
Hi,

I've spotted a possible memory leakage/violation in the latest R v2.1.1 
patched and R v2.2.0dev on Windows XP Pro SP2 Eng.

I first caught it deep down in a nested svd algorithm when subtracting a 
double 'c' from a integer vector 'a' where both had finite values but 
when assigning 'a <- a - c' would report NaNs whereas (a-c) alone would 
not.  Different runs with the identical data would introduce NaNs at 
random positions, but not all the time.

Troubleshooting is after a couple of hours still at v0.5, but here is a 
script that generates the strange behavior on the above R setups.  I let 
the script speak for itself.  Note that both the script 'strange.R' and 
the data 'strange.RData' is online too, see code below.

People on other systems (but also on Windows), could you please try it 
and see if you can reproduce what I get.

Cheers

Henrik


# The following was tested on: Windows XP Pro SP2 Eng with
#   i) R Version 2.1.1 Patched (2005-08-25)
#  ii) R 2.2.0 Under development (unstable) (2005-08-25 r35394M)

# Start 'R --vanilla' and source() this script, i.e.
#  source("http://www.maths.lth.se/help/R/strange.R";)
# If you do not get any errors, retry a few times.

foo <- function(x) {
   print(list(
 name=as.character(substitute(x)),
 storage.mode=storage.mode(x),
 na=any(is.na(x)),
 nan=any(is.nan(x)),
 inf=any(is.infinite(x)),
 ok=all(is.finite(a))
   ))
   print(length(x))
   print(summary(x))
}

# Load data from a complicated "non-reproducible" algorithm.
# The below errors occur also when data is not
# saved and then reloaded from file.  Data was generated in
# R v2.1.1 patched (see above).
if (file.exists("strange.RData")) {
   load("strange.RData")
} else {
   load(url("http://www.maths.lth.se/help/R/strange.RData";))
}

# First glance at data...
foo(a)
foo(c)

## $name
## [1] "a"
##
## $storage.mode
## [1] "integer"
##
## $na
## [1] FALSE
##
## $nan
## [1] FALSE
##
## $inf
## [1] FALSE
##
## $ok
## [1] TRUE
##
## [1] 15000
##Min. 1st Qu.  MedianMean 3rd Qu.Max.
##41.051.063.0   292.2   111.0 65170.0
## $name
## [1] "c"
##
## $storage.mode
## [1] "double"
##
## $na
## [1] FALSE
##
## $nan
## [1] FALSE
##
## $inf
## [1] FALSE
##
## $ok
## [1] TRUE
##
## [1] 1
##Min. 1st Qu.  MedianMean 3rd Qu.Max.
##   53.43   53.43   53.43   53.43   53.43   53.43
##

# But, trying the following, will result in
# no-reproducible error messages. Sometimes
# it errors at kk==1, sometimes at kk >> 1.
# Also, look at the different output for
# different kk:s.
for (kk in 1:100) {
   cat("kk=",kk, "\n")
   print(summary(a-c))
}

## kk= 1
##Min. 1st Qu.  MedianMean 3rd Qu.Max.
## -7.741e+307  -2.431e+00   9.569e+00   5.757e+01
## kk= 2
##  Min.   1st Qu.Median  Mean   3rd Qu.  Max.
##   -12.430-2.431 9.569   238.70057.570 65120.000
## kk= 3
##  Min.   1st Qu.Median  Mean   3rd Qu.  Max.
##   -12.430-2.431 9.569  57.570 65120.000
## kk= 4
##  Min.   1st Qu.Median  Mean   3rd Qu.  Max.
##   -12.430-2.431 9.569   238.70057.570 65120.000
## kk= 5
##  Min.   1st Qu.Median  Mean   3rd Qu.  Max.
##   -12.430-2.431 9.569   238.70057.570 65120.000
## kk= 6
## Error in quantile.default(object) : missing values and NaN's
## not allowed if 'na.rm' is FALSE


## Comments: If you shorten down 'a', the bug occurs less frequently.

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


Re: [Rd] Free-form to fixed-form Fortran

2005-08-26 Thread Don MacQueen
Not knowing exactly what you mean by Free-form Fortran I couldn't say 
for sure, but
perhaps ratfor will do the job. Worth trying, I would think.

-Don

At 4:36 PM +0200 8/26/05, =?iso-8859-2?Q?Ale=B9_=AEiberna?= wrote:
>Hello!
>
>I have writen some subrutines in Free-form Fortran. I would like to includ
>them in a package, which I would like to build on WinXP. I have all
>suggested tools/programs for bulding R packages on Windows (except latex).
>
>What is the best way of using these subrutines? Does sombody mybe know any
>translation tools for converting Free-form to fixed-form Fortran?
>
>Thanks for any suggestions,
>Ales Ziberna
>
>__
>R-devel@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

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


Re: [Rd] Free-form to fixed-form Fortran

2005-08-26 Thread Simon Urbanek
Aleši,

On Aug 26, 2005, at 10:36 AM, Aleš Žiberna wrote:

> I have writen some subrutines in Free-form Fortran. I would like to  
> includ
> them in a package, which I would like to build on WinXP. I have all
> suggested tools/programs for bulding R packages on Windows (except  
> latex).
>
> What is the best way of using these subrutines? Does sombody mybe  
> know any
> translation tools for converting Free-form to fixed-form Fortran?

If your only concern is to build it, you may try using g77 with - 
ffree-form. This should work with GNU Fortran. However, that limits  
the availability of your package to GNU compilers only.

Cheers,
Šimon

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


Re: [Rd] Memory leakage/violation?

2005-08-26 Thread Thomas Lumley

I can't reproduce this on R2.2.0dev on Windows XP (in a few hundred 
tries), or running under Valgrind on AMD64 Linux (in four or five tries).

-thomas


On Fri, 26 Aug 2005, Henrik Bengtsson wrote:

> Hi,
>
> I've spotted a possible memory leakage/violation in the latest R v2.1.1
> patched and R v2.2.0dev on Windows XP Pro SP2 Eng.
>
> I first caught it deep down in a nested svd algorithm when subtracting a
> double 'c' from a integer vector 'a' where both had finite values but
> when assigning 'a <- a - c' would report NaNs whereas (a-c) alone would
> not.  Different runs with the identical data would introduce NaNs at
> random positions, but not all the time.
>
> Troubleshooting is after a couple of hours still at v0.5, but here is a
> script that generates the strange behavior on the above R setups.  I let
> the script speak for itself.  Note that both the script 'strange.R' and
> the data 'strange.RData' is online too, see code below.
>
> People on other systems (but also on Windows), could you please try it
> and see if you can reproduce what I get.
>
> Cheers
>
> Henrik
>
>
> # The following was tested on: Windows XP Pro SP2 Eng with
> #   i) R Version 2.1.1 Patched (2005-08-25)
> #  ii) R 2.2.0 Under development (unstable) (2005-08-25 r35394M)
>
> # Start 'R --vanilla' and source() this script, i.e.
> #  source("http://www.maths.lth.se/help/R/strange.R";)
> # If you do not get any errors, retry a few times.
>
> foo <- function(x) {
>   print(list(
> name=as.character(substitute(x)),
> storage.mode=storage.mode(x),
> na=any(is.na(x)),
> nan=any(is.nan(x)),
> inf=any(is.infinite(x)),
> ok=all(is.finite(a))
>   ))
>   print(length(x))
>   print(summary(x))
> }
>
> # Load data from a complicated "non-reproducible" algorithm.
> # The below errors occur also when data is not
> # saved and then reloaded from file.  Data was generated in
> # R v2.1.1 patched (see above).
> if (file.exists("strange.RData")) {
>   load("strange.RData")
> } else {
>   load(url("http://www.maths.lth.se/help/R/strange.RData";))
> }
>
> # First glance at data...
> foo(a)
> foo(c)
>
> ## $name
> ## [1] "a"
> ##
> ## $storage.mode
> ## [1] "integer"
> ##
> ## $na
> ## [1] FALSE
> ##
> ## $nan
> ## [1] FALSE
> ##
> ## $inf
> ## [1] FALSE
> ##
> ## $ok
> ## [1] TRUE
> ##
> ## [1] 15000
> ##Min. 1st Qu.  MedianMean 3rd Qu.Max.
> ##41.051.063.0   292.2   111.0 65170.0
> ## $name
> ## [1] "c"
> ##
> ## $storage.mode
> ## [1] "double"
> ##
> ## $na
> ## [1] FALSE
> ##
> ## $nan
> ## [1] FALSE
> ##
> ## $inf
> ## [1] FALSE
> ##
> ## $ok
> ## [1] TRUE
> ##
> ## [1] 1
> ##Min. 1st Qu.  MedianMean 3rd Qu.Max.
> ##   53.43   53.43   53.43   53.43   53.43   53.43
> ##
>
> # But, trying the following, will result in
> # no-reproducible error messages. Sometimes
> # it errors at kk==1, sometimes at kk >> 1.
> # Also, look at the different output for
> # different kk:s.
> for (kk in 1:100) {
>   cat("kk=",kk, "\n")
>   print(summary(a-c))
> }
>
> ## kk= 1
> ##  Min. 1st Qu.  MedianMean 3rd Qu.Max.
> ## -7.741e+307  -2.431e+00   9.569e+00   5.757e+01
> ## kk= 2
> ##Min.   1st Qu.Median  Mean   3rd Qu.  Max.
> ##   -12.430-2.431 9.569   238.70057.570 65120.000
> ## kk= 3
> ##Min.   1st Qu.Median  Mean   3rd Qu.  Max.
> ##   -12.430-2.431 9.569  57.570 65120.000
> ## kk= 4
> ##Min.   1st Qu.Median  Mean   3rd Qu.  Max.
> ##   -12.430-2.431 9.569   238.70057.570 65120.000
> ## kk= 5
> ##Min.   1st Qu.Median  Mean   3rd Qu.  Max.
> ##   -12.430-2.431 9.569   238.70057.570 65120.000
> ## kk= 6
> ## Error in quantile.default(object) : missing values and NaN's
> ## not allowed if 'na.rm' is FALSE
>
>
> ## Comments: If you shorten down 'a', the bug occurs less frequently.
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

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


Re: [Rd] RFC: "loop connections"

2005-08-26 Thread dhinds
I accidentally left one small change out of my previous patch.

So... no response to my request for comments.  Does that mean no one
has an opinion about whether this is a good idea or not?  I'd
appreciate a response from an R core member one way or the other; if
this is not the right way to get a response, should I email people
instead?

-- David Hinds


--- src/include/Internal.h.orig 2005-05-20 05:51:37.0 -0700
+++ src/include/Internal.h  2005-08-22 15:46:48.968190600 -0700
@@ -518,7 +518,7 @@
 SEXP do_pushback(SEXP, SEXP, SEXP, SEXP);
 SEXP do_pushbacklength(SEXP, SEXP, SEXP, SEXP);
 SEXP do_clearpushback(SEXP, SEXP, SEXP, SEXP);
-SEXP do_textconnection(SEXP, SEXP, SEXP, SEXP);
+SEXP do_loopconnection(SEXP, SEXP, SEXP, SEXP);
 SEXP do_getallconnections(SEXP, SEXP, SEXP, SEXP);
 SEXP do_sumconnection(SEXP, SEXP, SEXP, SEXP);
 SEXP do_download(SEXP, SEXP, SEXP, SEXP);

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


Re: [Rd] RFC: "loop connections"

2005-08-26 Thread Gabor Grothendieck
OK.  I guess you want one of the core people to respond but in the
interim can you explain the terminology "loop"?   
Also, do you have any prototypical applications in mind?

On 8/26/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I accidentally left one small change out of my previous patch.
> 
> So... no response to my request for comments.  Does that mean no one
> has an opinion about whether this is a good idea or not?  I'd
> appreciate a response from an R core member one way or the other; if
> this is not the right way to get a response, should I email people
> instead?
> 
> -- David Hinds
> 
> 
> --- src/include/Internal.h.orig 2005-05-20 05:51:37.0 -0700
> +++ src/include/Internal.h  2005-08-22 15:46:48.968190600 -0700
> @@ -518,7 +518,7 @@
>  SEXP do_pushback(SEXP, SEXP, SEXP, SEXP);
>  SEXP do_pushbacklength(SEXP, SEXP, SEXP, SEXP);
>  SEXP do_clearpushback(SEXP, SEXP, SEXP, SEXP);
> -SEXP do_textconnection(SEXP, SEXP, SEXP, SEXP);
> +SEXP do_loopconnection(SEXP, SEXP, SEXP, SEXP);
>  SEXP do_getallconnections(SEXP, SEXP, SEXP, SEXP);
>  SEXP do_sumconnection(SEXP, SEXP, SEXP, SEXP);
>  SEXP do_download(SEXP, SEXP, SEXP, SEXP);
> 
> __
> 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] .Call and Segmentation Fault

2005-08-26 Thread Ricardo Luiz Andrade Abrantes
Hello to everyone!
I use .Call to call a C function without arguments wich calls a
fortran optimization package. My C function uses others C and Fortran
functions and it works fine when I call it from a main() in a C
program. But when I call it from R with
.Call("name_of_the_c_function"), R gives me some weird output.
This weird output is a worng answer to my optimization problem
(sometimes after thousands iteractions, what does not occur when
called from C) or a segmentation fault error. The kind of output
depends on the machine I am using. At home I got a segmentation faul,
in university I got those wrong values.
I tried a memcheck in C and Fortran binaries, but everything seems
allright except by 2 missing free() calls (wich I don`t think might be
causing this error).
I compiled my C and Fortran files with R CMD SHARED and then linked
all the .o with the same command. I also tried compiling all the
needed object files with -fPIC and -shared and then using R CMD SHARED
to link everything, but I got the same problem.
The only thing I do in R is the following:

dyn.load("mylib.so")
.Call("name_of_the_c_function")

Can someone hellp me with this?


   Thanks!


 Ricardo

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


Re: [Rd] .Call and Segmentation Fault

2005-08-26 Thread Byron Ellis
Are you returning a SEXP? .Call (unlike .C) expects a SEXP return  
value. It sounds like you're returning garbage and R is choking on  
that when it tries to use the address as a SEXP.

On Aug 26, 2005, at 3:19 PM, Ricardo Luiz Andrade Abrantes wrote:

> Hello to everyone!
> I use .Call to call a C function without arguments wich calls a
> fortran optimization package. My C function uses others C and Fortran
> functions and it works fine when I call it from a main() in a C
> program. But when I call it from R with
> .Call("name_of_the_c_function"), R gives me some weird output.
> This weird output is a worng answer to my optimization problem
> (sometimes after thousands iteractions, what does not occur when
> called from C) or a segmentation fault error. The kind of output
> depends on the machine I am using. At home I got a segmentation faul,
> in university I got those wrong values.
> I tried a memcheck in C and Fortran binaries, but everything seems
> allright except by 2 missing free() calls (wich I don`t think might be
> causing this error).
> I compiled my C and Fortran files with R CMD SHARED and then linked
> all the .o with the same command. I also tried compiling all the
> needed object files with -fPIC and -shared and then using R CMD SHARED
> to link everything, but I got the same problem.
> The only thing I do in R is the following:
>
> dyn.load("mylib.so")
> .Call("name_of_the_c_function")
>
> Can someone hellp me with this?
>
>
>   Thanks!
>
>
> Ricardo
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

---
Byron Ellis ([EMAIL PROTECTED])
"Oook" -- The Librarian

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


[Rd] wchar and wstring.

2005-08-26 Thread James Bullard
Hello all, I am writing an R interface to some C++ files which make use
of std::wstring classes for internationalization. Previously (when I
wanted to make R strings from C++ std::strings), I would do something
like this to construct a string in R from the results of the parse.

SET_VECTOR_ELT(vals, i++, mkString(header.GetHeader().c_str()));


However, now the call header.GetHeader().c_str() returns a pointer to an
array of wchar_t's. I was going to use
wcstombs() to convert the wchar_t* to char*, but I wanted to see if
there was a similar function in R for the mkString function which I had
initially used which deals with wchar_ts as opposed to chars. Also,
since I have no experience with the wctombs() function I wanted to ask
if anyone knew if this will handle the internationilzation issues from
within R.


As always thank you for the help. jim

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


[Rd] .Call and Segmentation Fault

2005-08-26 Thread Ricardo Luiz Andrade Abrantes
Hello to everyone!
I use .Call to call a C function without arguments wich calls a
fortran optimization package. My C function uses others C and Fortran
functions and it works fine when I call it from a main() in a C
program. But when I call it from R with
.Call("name_of_the_c_function"), R gives me some weird output.
This weird output is a worng answer to my optimization problem
(sometimes after thousands iteractions, what does not occur when
called from C) or a segmentation fault error. The kind of output
depends on the machine I am using. At home I got a segmentation faul,
in university I got those wrong values.
I tried a memcheck in C and Fortran binaries, but everything seems
allright except by 2 missing free() calls (wich I don`t think might be
causing this error).
I compiled my C and Fortran files with R CMD SHARED and then linked
all the .o with the same command. I also tried compiling all the
needed object files with -fPIC and -shared and then using R CMD SHARED
to link everything, but I got the same problem.
The only thing I do in R is the following:

dyn.load("mylib.so")
.Call("name_of_the_c_function")

Can someone hellp me with this?


  Thanks!


Ricardo

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


Re: [Rd] RFC: "loop connections"

2005-08-26 Thread dhinds
Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> OK.  I guess you want one of the core people to respond but in the
> interim can you explain the terminology "loop"?   
> Also, do you have any prototypical applications in mind?

"loop" is short for "loopback".  A loop or loopback device is one that
just returns the data sent to it.

The prototypical applications are the same sort of applications text
connections are used for: data transformation, in this case of raw
binary data, rather than formatted text data.  In my case, I needed to
interpret a "long raw" column from an Oracle table, that consisted of
packed single precision floating point numbers.

The caTools package on CRAN includes less capable raw2bin and bin2raw
functions, used to implement Base64 encoders and decoders.

-- Dave

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