Re: [Rd] RNGkind() state (PR#12567)

2008-08-20 Thread Prof Brian Ripley

On Tue, 19 Aug 2008, [EMAIL PROTECTED] wrote:


I sent this to R-devel early last month, but have received no response, so I 
guess it
really is a bug.


Or people were busy: I was away teaching a course, for example.


This looks like a bug to me, and is a bit hard to describe, but easy to 
reproduce.  
Basically, if RNGkind is saved as something other than the default, and if the 
first
operation in a session is a set.seed(), the default is reverted to.  Reproduce 
by:


A better description would certainly have helped!  You can look at 
.Random.seed to see what is happening.


I think what you are observing is that if .Random.seed has not used in the 
session, any restored value is not used to set the default kind in 
set.seed.  I don't think that is unreasonable (in particular as you can 
set the kind in set.seed() and I take the notes on ?RNG to suggest that), 
but would be easy to change/document.




cafe-rozo>  R --vanilla

R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


sessionInfo()

R version 2.7.1 (2008-06-23)
i386--netbsdelf

locale:
C

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

set.seed(1); runif(1) # check the default

[1] 0.2655087

RNGkind("Mar")
RNGkind()

[1] "Marsaglia-Multicarry" "Inversion"

set.seed(1); runif(1) # now check again

[1] 0.006153224

set.seed(1)   # save seed and RNGkind
q("yes")

cafe-rozo>  R

R version 2.7.1 (2008-06-23)
: etc
[Previously saved workspace restored]


runif(1)  # with a saved seed, Marsaglia-Multicarry is used

[1] 0.006153224

set.seed(1); runif(1)

[1] 0.006153224

q()

Save workspace image? [y/n/c]: n
cafe-rozo>

R version 2.7.1 (2008-06-23)
: etc
[Previously saved workspace restored]


set.seed(1); runif(1) # saved RNGkind is ignored ...

[1] 0.2655087

RNGkind() # and overridden ...

[1] "Mersenne-Twister" "Inversion"

q("no")

cafe-rozo>  R

R version 2.7.1 (2008-06-23)
: etc
[Previously saved workspace restored]


RNGkind() # and wrongly reported!

[1] "Mersenne-Twister" "Inversion"

runif(1)  # Note this is actually using Marsaglia-Multicarry

[1] 0.006153224




Ray Brownrigg
Mathematics, Statistics and Computer Science
Victoria University of Wellington
Wellington, NZ

__
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__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Outdated dependencies and install.packages()

2008-08-20 Thread Peter Dalgaard
This looks like a buglet:

> install.packages("lme4", depend=TRUE, lib="~/Rlibrary/")
--- Please select a CRAN mirror for use in this session ---
[...snip...]
** preparing package for lazy loading
Error: package 'Matrix' 0.999375-4 was found, but >= 0.999375.11 is
required by 'lme4'
Execution halted
ERROR: lazy loading failed for package 'lme4'
** Removing '/home/bs/pd/Rlibrary/lme4'
** Restoring previous '/home/bs/pd/Rlibrary/lme4'

and the DESCRIPTION file for lme 4 does have

Depends: methods, R(≥ 2.7.0), Matrix(≥ 0.999375-11), lattice



Looks like we're either not checking the version requirement of
dependencies, or something is making 4 > 11... (from my reading of the
code, it is the former, but I could have missed something).

We should at least document the behaviour.

-- 
   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-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] showMethods("plot", printTo=FALSE) fails if printTo set to FALSE

2008-08-20 Thread Sklyar, Oleg (London)
Hi everybody,

any idea why showMethods fails with the following error when printTo is
set to false, i.e. to return the output as a character vector. It works
fine if printTo is left default as seen below. The behaviour is
consistent for any method I tried. stdin() generally works fine on this
system, at least when checked with: x = readLines().

Thanks,
Oleg

> x = showMethods("plot", printTo=FALSE)
Error in cat(file = printTo, sep = "", ...) : 
  cannot switch output to stdin

Enter a frame number, or 0 to exit   

1: showMethods("plot", printTo = FALSE)
2: .showMethodsTable(fdef, includeDefs, inherited, classes = classes,
showEmpt
3: doFun(f, p)
4: cf("Function: ", func, " (package ", pkg, ")\n")
5: cat(file = printTo, sep = "", ...)

Selection: 0
> x = showMethods("plot")
Function: plot (package graphics)
x="ANY", y="ANY"
x="SimResults", y="SimResults"
x="SimResults", y="missing"
x="TimeDateBase", y="character"
x="TimeDateBase", y="data.frameOrMatrix"
x="TimeDateBase", y="missing"
x="TimeSeries", y="missing"

> sessionInfo()
R version 2.8.0 Under development (unstable) (2008-08-05 r46234) 
x86_64-unknown-linux-gnu 

locale:
C

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

[8] base 

other attached packages:

## 64bit RHEL 5


Dr Oleg Sklyar
Technology Group
Man Investments Ltd
+44 (0)20 7144 3803
[EMAIL PROTECTED]


**
The contents of this email are for the named addressee(s...{{dropped:22}}

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


Re: [Rd] showMethods("plot", printTo=FALSE) fails if printTo set to FALSE

2008-08-20 Thread Prof Brian Ripley

On Wed, 20 Aug 2008, Sklyar, Oleg (London) wrote:


Hi everybody,

any idea why showMethods fails with the following error when printTo is
set to false, i.e. to return the output as a character vector. It works
fine if printTo is left default as seen below. The behaviour is
consistent for any method I tried. stdin() generally works fine on this
system, at least when checked with: x = readLines().

Thanks,
Oleg


x = showMethods("plot", printTo=FALSE)

Error in cat(file = printTo, sep = "", ...) :
 cannot switch output to stdin


This has coerced FALSE to 0, which is connection stdin().  You cannot 
write to stdin.


I see no sign that printTo = FALSE has been implemented.  You could use a 
text connection, e.g.


con <- textConnection(NULL, open="w")
x <- showMethods("plot", printTo=con)
textConnectionValue(con)
close(con)



Enter a frame number, or 0 to exit

1: showMethods("plot", printTo = FALSE)
2: .showMethodsTable(fdef, includeDefs, inherited, classes = classes,
showEmpt
3: doFun(f, p)
4: cf("Function: ", func, " (package ", pkg, ")\n")
5: cat(file = printTo, sep = "", ...)

Selection: 0

x = showMethods("plot")

Function: plot (package graphics)
x="ANY", y="ANY"
x="SimResults", y="SimResults"
x="SimResults", y="missing"
x="TimeDateBase", y="character"
x="TimeDateBase", y="data.frameOrMatrix"
x="TimeDateBase", y="missing"
x="TimeSeries", y="missing"


sessionInfo()

R version 2.8.0 Under development (unstable) (2008-08-05 r46234)
x86_64-unknown-linux-gnu

locale:
C

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

[8] base

other attached packages:

## 64bit RHEL 5


Dr Oleg Sklyar
Technology Group
Man Investments Ltd
+44 (0)20 7144 3803
[EMAIL PROTECTED]


**
The contents of this email are for the named addressee(s...{{dropped:22}}

__
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

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


Re: [Rd] showMethods("plot", printTo=FALSE) fails if printTo set to FALSE

2008-08-20 Thread Sklyar, Oleg (London)
Thanks for a good tip.

Dr Oleg Sklyar
Technology Group
Man Investments Ltd
+44 (0)20 7144 3803
[EMAIL PROTECTED] 

> -Original Message-
> From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
> Sent: 20 August 2008 13:29
> To: Sklyar, Oleg (London)
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Rd] showMethods("plot", printTo=FALSE) fails if 
> printTo set to FALSE
> 
> On Wed, 20 Aug 2008, Sklyar, Oleg (London) wrote:
> 
> > Hi everybody,
> >
> > any idea why showMethods fails with the following error 
> when printTo is
> > set to false, i.e. to return the output as a character 
> vector. It works
> > fine if printTo is left default as seen below. The behaviour is
> > consistent for any method I tried. stdin() generally works 
> fine on this
> > system, at least when checked with: x = readLines().
> >
> > Thanks,
> > Oleg
> >
> >> x = showMethods("plot", printTo=FALSE)
> > Error in cat(file = printTo, sep = "", ...) :
> >  cannot switch output to stdin
> 
> This has coerced FALSE to 0, which is connection stdin().  You cannot 
> write to stdin.
> 
> I see no sign that printTo = FALSE has been implemented.  You 
> could use a 
> text connection, e.g.
> 
> con <- textConnection(NULL, open="w")
> x <- showMethods("plot", printTo=con)
> textConnectionValue(con)
> close(con)
> 
> >
> > Enter a frame number, or 0 to exit
> >
> > 1: showMethods("plot", printTo = FALSE)
> > 2: .showMethodsTable(fdef, includeDefs, inherited, classes 
> = classes,
> > showEmpt
> > 3: doFun(f, p)
> > 4: cf("Function: ", func, " (package ", pkg, ")\n")
> > 5: cat(file = printTo, sep = "", ...)
> >
> > Selection: 0
> >> x = showMethods("plot")
> > Function: plot (package graphics)
> > x="ANY", y="ANY"
> > x="SimResults", y="SimResults"
> > x="SimResults", y="missing"
> > x="TimeDateBase", y="character"
> > x="TimeDateBase", y="data.frameOrMatrix"
> > x="TimeDateBase", y="missing"
> > x="TimeSeries", y="missing"
> >
> >> sessionInfo()
> > R version 2.8.0 Under development (unstable) (2008-08-05 r46234)
> > x86_64-unknown-linux-gnu
> >
> > locale:
> > C
> >
> > attached base packages:
> > [1] datasets  splines   utils stats graphics  
> grDevices methods
> >
> > [8] base
> >
> > other attached packages:
> >
> > ## 64bit RHEL 5
> >
> >
> > Dr Oleg Sklyar
> > Technology Group
> > Man Investments Ltd
> > +44 (0)20 7144 3803
> > [EMAIL PROTECTED]
> >
> >
> > 
> **
> > The contents of this email are for the named 
> addressee(s...{{dropped:22}}
> >
> > __
> > 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
> 


**
The contents of this email are for the named addressee(s...{{dropped:22}}

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


Re: [Rd] Outdated dependencies and install.packages()

2008-08-20 Thread Martin Morgan
A small addendum is that if the outdated dependency is in the
LinkingTo: field, the error can be more cryptic. Installation then
fails with compilation errors rather than the hint that the dependency
is out of date.

Martin Morgan

Peter Dalgaard <[EMAIL PROTECTED]> writes:

> This looks like a buglet:
>
>> install.packages("lme4", depend=TRUE, lib="~/Rlibrary/")
> --- Please select a CRAN mirror for use in this session ---
> [...snip...]
> ** preparing package for lazy loading
> Error: package 'Matrix' 0.999375-4 was found, but >= 0.999375.11 is
> required by 'lme4'
> Execution halted
> ERROR: lazy loading failed for package 'lme4'
> ** Removing '/home/bs/pd/Rlibrary/lme4'
> ** Restoring previous '/home/bs/pd/Rlibrary/lme4'
>
> and the DESCRIPTION file for lme 4 does have
>
> Depends: methods, R(≥ 2.7.0), Matrix(≥ 0.999375-11), lattice
> 
>
>
> Looks like we're either not checking the version requirement of
> dependencies, or something is making 4 > 11... (from my reading of the
> code, it is the former, but I could have missed something).
>
> We should at least document the behaviour.
>
> -- 
>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-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

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

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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


[Rd] unlist on nested lists of factors (PR#12572)

2008-08-20 Thread davison
Here is a description and a proposed solution for a bug in unlist().

I've used version 2.7.2 RC (2008-08-18 r46382) to look at this, under
linux.

unlist(recursive=TRUE) incorrectly returns a factor with zero levels
when passed either a nested list of factors, or a data frame
containing only factor columns. You can't print() the result.

x <- list(list(v=factor("a")))
str(unlist(x))
## Factor w/ 0 levels: NA
## - attr(*, "names")= chr "v"
## Warning message:
## In str.default(unlist(x)) : 'object' does not have valid levels() 
y <- list(data.frame(v=factor("a")))
str(unlist(y))
## Factor w/ 0 levels: NA
## - attr(*, "names")= chr "v"
## Warning message:
## In str.default(unlist(y)) : 'object' does not have valid levels()

unlist is defined as

unlist <- function(x, recursive=TRUE, use.names=TRUE)
{
if(.Internal(islistfactor(x, recursive))) {
lv <- unique(.Internal(unlist(lapply(x, levels), recursive, FALSE)))
nm <- if(use.names) names(.Internal(unlist(x, recursive, use.names)))
res <- .Internal(unlist(lapply(x, as.character), recursive, FALSE))
res <- match(res, lv)
## we cannot make this ordered as level set may have been changed
structure(res, levels=lv, names=nm, class="factor")
} else .Internal(unlist(x, recursive, use.names))
}

The error occurs because, in both cases, at the C level, islistfactor
recurses and finds that all elements are factors, and the if test
condition is TRUE. However, the two instances of lapply do not
recurse, and return inappropriate results. A possible solution is to
replace both instances of lapply with rapply. This results in
appropriate factor answers in this case:

str(unlist(x))
## Factor w/ 1 level "a": 1
## - attr(*, "names")= chr "v"
str(unlist(y))
## Factor w/ 1 level "a": 1
## - attr(*, "names")= chr "v"

An alternative is to not return a factor result, by altering the if
test condition so that nested lists of factors, and lists of
factor-only data frames, fail.


Dan

-- 
www.stats.ox.ac.uk/~davison

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


Re: [Rd] Outdated dependencies and install.packages()

2008-08-20 Thread Prof Brian Ripley

On Wed, 20 Aug 2008, Peter Dalgaard wrote:


This looks like a buglet:


install.packages("lme4", depend=TRUE, lib="~/Rlibrary/")

--- Please select a CRAN mirror for use in this session ---
[...snip...]
** preparing package for lazy loading
Error: package 'Matrix' 0.999375-4 was found, but >= 0.999375.11 is
required by 'lme4'
Execution halted
ERROR: lazy loading failed for package 'lme4'
** Removing '/home/bs/pd/Rlibrary/lme4'
** Restoring previous '/home/bs/pd/Rlibrary/lme4'

and the DESCRIPTION file for lme 4 does have

Depends: methods, R(≥ 2.7.0), Matrix(≥ 0.999375-11), lattice



Looks like we're either not checking the version requirement of
dependencies, or something is making 4 > 11... (from my reading of the
code, it is the former, but I could have missed something).


We don't check version requirements of dependencies in install.packages(). 
That's a minefield related to having multiple versions of a package on a 
system and which gets loaded/namespace loaded, so you can easily have the 
needed version but pick up a different one.


Depending on whether lazy-loading is in place (and various other issues) 
you may or may not need the dependencies to install the package.  It's 
also a problem that you can update dependencies to incompatible ones, so 
the versions available at installation are only part of the story.


I don't see why the message reports .11 not -11, but that may be 
related to "package_version" classes.



We should at least document the behaviour.


I am not sure where you think it should be documented and is not.
But for install.packages():

dependencies: logical indicating to also install uninstalled packages
  on which these packages depend/suggest/import (and so on
  recursively).  Not used if 'repos = NULL'. Can also be a
  character vector, a subset of 'c("Depends", "Imports",
  "Suggests")'.

'uninstalled' seems pretty clear to me.

--
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


Re: [Rd] Outdated dependencies and install.packages()

2008-08-20 Thread Peter Dalgaard
Prof Brian Ripley wrote:
> On Wed, 20 Aug 2008, Peter Dalgaard wrote:
>
>> This looks like a buglet:
>>
>>> install.packages("lme4", depend=TRUE, lib="~/Rlibrary/")
>> --- Please select a CRAN mirror for use in this session ---
>> [...snip...]
>> ** preparing package for lazy loading
>> Error: package 'Matrix' 0.999375-4 was found, but >= 0.999375.11 is
>> required by 'lme4'
>> Execution halted
>> ERROR: lazy loading failed for package 'lme4'
>> ** Removing '/home/bs/pd/Rlibrary/lme4'
>> ** Restoring previous '/home/bs/pd/Rlibrary/lme4'
>>
>> and the DESCRIPTION file for lme 4 does have
>>
>> Depends: methods, R(≥ 2.7.0), Matrix(≥ 0.999375-11), lattice
>> 
>>
>>
>> Looks like we're either not checking the version requirement of
>> dependencies, or something is making 4 > 11... (from my reading of the
>> code, it is the former, but I could have missed something).
>
> We don't check version requirements of dependencies in
> install.packages(). That's a minefield related to having multiple
> versions of a package on a system and which gets loaded/namespace
> loaded, so you can easily have the needed version but pick up a
> different one.
>
> Depending on whether lazy-loading is in place (and various other
> issues) you may or may not need the dependencies to install the
> package.  It's also a problem that you can update dependencies to
> incompatible ones, so the versions available at installation are only
> part of the story.
>
> I don't see why the message reports .11 not -11, but that may be
> related to "package_version" classes.
>
>> We should at least document the behaviour.
>
> I am not sure where you think it should be documented and is not.
> But for install.packages():
>
> dependencies: logical indicating to also install uninstalled packages
>   on which these packages depend/suggest/import (and so on
>   recursively).  Not used if 'repos = NULL'. Can also be a
>   character vector, a subset of 'c("Depends", "Imports",
>   "Suggests")'.
>
> 'uninstalled' seems pretty clear to me.
>
It isn't. Matrix 0.999375-11 was 'uninstalled'. The above could just
mean that if you installed it, it wouldn't be installed again.

Something like "Notice that version dependencies are not checked." would
help. (Assuming that people read the help page.)

-- 
   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-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] unlist on nested pairlists

2008-08-20 Thread Dan Davison
unlist(recursive=FALSE) returns NULL elements when passed a nested
pairlist containing non-NULL data:

x <- pairlist(pairlist(1:2))
unlist(x, recursive=FALSE)
## [[1]]
## NULL

version 2.7.2 RC (2008-08-18 r46382) under linux

I'm unaware of any motivation for constructing the above data
structure, but if unlist is going to operate on it without error I
would be surprised if that is the correct answer. However as I do not
know anything about pairlists I have not submitted this to r-bugs.

I'd also appreciate any comments on the following issue:

The documentation for unlist says

recursive: logical.  Should unlisting be applied to list components of
  'x'?

Now,

y <- list(a=1:2, b=list(b1=3:4, b2=5:6))

My expectation was that unlist(y, recursive=FALSE) would be the following 
length 3 list:
list(a1=1, a2=2, b=list(b1=3:4, b2=5:6))

However

str(unlist(y, recursive=FALSE))
## List of 4
## $ a1  : int 1
## $ a2  : int 2
## $ b.b1: int [1:2] 3 4
## $ b.b2: int [1:2] 5 6

I'm tempted to say that, contary to the documentation, (partial)
unlisting has in fact been applied to a list component of x (x$b): it
contributes 2 components to the result, rather than one. I say partial
because the numeric vectors in x$b have not been broken up into
separate elements in the answer. However, I imagine that this is the
intended behaviour, and that my incorrect expectation is a result of
not understanding the underlying list representations. Any explanation
would be appreciated.

Dan

-- 
http://www.stats.ox.ac.uk/~davison

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


[Rd] names of return value of median

2008-08-20 Thread Vadim Organovich
Dear R-devel,

The median() function assigns a name, "NA", to its return value if the return 
value is NA and the input vector has names, otherwise the names attribute is 
NULL. This looks strange and inconsistent with the behavior of mean().

This inconsistency becomes a problem when median() is used inside user code 
that relies on consistent naming convention.

Thanks,
Vadim

> foo <- c(x=as.numeric(NA), y=as.numeric(NA), z=as.numeric(NA))
> names(mean(foo))
NULL
> names(median(foo))
[1] NA

## no names in input
> foo <- rep(as.numeric(NA), 3)
> names(median(foo))
NULL


> version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  7.1
year   2008
month  06
day23
svn rev45970
language   R
version.string R version 2.7.1 (2008-06-23)
>

Note: This email is for the confidential use of the named addressee(s) only and 
may contain proprietary, confidential or privileged information. If you are not 
the intended recipient, you are hereby notified that any review, dissemination 
or copying of this email is strictly prohibited, and to please notify the 
sender immediately and destroy this email and any attachments.  Email 
transmission cannot be guaranteed to be secure or error-free.  Jump Trading, 
therefore, does not make any guarantees as to the completeness or accuracy of 
this email or any attachments.  This email is for informational purposes only 
and does not constitute a recommendation, offer, request or solicitation of any 
kind to buy, sell, subscribe, redeem or perform any type of transaction of a 
financial product.

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


[Rd] R-Embedding and error messages

2008-08-20 Thread Jorge W. Cardoso
I'm writing a C++ application using R-embedding to do some
forecast process.

I also use R_tryEval instead of R_Eval to run my R-script,
so that in case of error I know exactly in which line number
was the last error.

In particular, from time in time y get some error messages
refering an exceptional condition in the arima model.

I want to catch these error messages from de C code 
(or at least the code error number) to take some 
corrective actions.

Is there any way to do that ?

Regards,

Jorge W. Cardoso

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


[Rd] row.names in data.frame with row.names NULL

2008-08-20 Thread Vadim Organovich
Dear R-devel,

It appears that data.frame ignores row.names=NULL argument if it can guess the 
names from the first column. This behavior seems to contradict what the help 
page says, see the last sentence:

 If row names are not supplied in the call to 'data.frame', the row
 names are taken from the first component that has suitable names,
 for example a named vector or a matrix with rownames or a data
 frame. (If that component is subsequently recycled, the names are
 discarded with a warning.)  If 'row.names' was supplied as 'NULL'
 or no suitable component was found the row names are the integer
 sequence starting at one (and such row names are considered to be
 'automatic', and not preserved by 'as.matrix').

Probably it should read "AND no suitable component was found ...", but I like 
the promise of the original description better.

Thanks,
Vadim


> row.names(data.frame(x=c(a=1,b=2), row.names=NULL))
[1] "a" "b"
> version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  7.1
year   2008
month  06
day23
svn rev45970
language   R
version.string R version 2.7.1 (2008-06-23)
>

Note: This email is for the confidential use of the named addressee(s) only and 
may contain proprietary, confidential or privileged information. If you are not 
the intended recipient, you are hereby notified that any review, dissemination 
or copying of this email is strictly prohibited, and to please notify the 
sender immediately and destroy this email and any attachments.  Email 
transmission cannot be guaranteed to be secure or error-free.  Jump Trading, 
therefore, does not make any guarantees as to the completeness or accuracy of 
this email or any attachments.  This email is for informational purposes only 
and does not constitute a recommendation, offer, request or solicitation of any 
kind to buy, sell, subscribe, redeem or perform any type of transaction of a 
financial product.

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


[Rd] Improvements to write.arff (PR#12574)

2008-08-20 Thread martin
Full_Name: Martin C. Martin
Version: 2.7.1
OS: Ubuntu
Submission from: (NULL) (75.150.115.86)


The function write.arff, in the foreign library:

- Can produce relation names with invalid characters
- Doesn't use colnames() for attribute names when writing a matrix.

Here's a better version:

write.arff <- function (x, file, eol = "\n") 
{
if (file == "") 
file <- stdout()
else if (is.character(file)) {
file <- file(file, "w")
on.exit(close(file))
}
if (!inherits(file, "connection")) 
stop("Argument 'file' must be a character string or connection.")
if (!is.data.frame(x) && !is.matrix(x)) 
x <- data.frame(x)
squote <- function(s) {
ifelse(is.na(s), s, sprintf("'%s'", gsub("(['\\])", "\\1", 
s)))
}
text <- paste('@relation "', make.names(deparse(substitute(x))), '"',
sep='')
writeLines(text, file, sep = eol)
for (name in colnames(x)) {
text <- paste("@attribute", name)
if (is.data.frame(x) && is.factor(x[[name]])) {
lev <- squote(levels(x[[name]]))
levels(x[[name]]) <- lev
text <- paste(text, " {", paste(lev, collapse = ","), 
"}", sep = "")
}
else if (is.character(x[,name])) {
text <- paste(text, "string")
x[,name] <- squote((x[,name]))
}
else if (inherits(x[,name], "POSIXt")) {
text <- paste(text, "date \"-MM-dd hh:mm:ss\"")
x[,name] <- squote(format(x[,name]))
}
else {
text <- paste(text, "numeric")
}
writeLines(text, file, sep = eol)
}
writeLines("@data", file)
write.table(x, file = file, na = "?", sep = ",", eol = eol, 
quote = FALSE, row.names = FALSE, col.names = FALSE)
}

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


[Rd] java.lang.UnsatisfiedLinkError: The specified procedure could not be found error message

2008-08-20 Thread Vladmir Makarov
Dear Members,
I have developed a program which calls clustering libraries from R.
Everything works fine on my laptop. But when I installed the program
on another computer, the program gives me the error message:

Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed
in java.library.path.
java.lang.UnsatisfiedLinkError: C:\eclipse\lib\rJava\jri.dll: The
specified procedure could not be found

I don't understand what it does not like and what procedure it is looking for.

1. PATH is set correctly to the R.dll directory in Program files:
C:\Program Files\R\R-2.6.2\bin
2. R_HOME is set to C:\Program Files\R\R-2.6.2\bin
3. java.library.path is set to C:\eclipse\lib\rJava and JRI.jar and
JRI.dll are both there, so the messge is incorrect - native library IS
in directory listed in java.library.path.
4. Finally, there is only one installation of R on that computer, same
version as on my laptop, which excludes version conflict

Any hint will be highly appreciated,
Thank you in advance,
Vlad


-- 
***
 Dr. Vladimir Makarov
 Instructor, Computer Science Department
 School of Computer Science and Information Systems
 Pace University
 163 Williams Street
 New York, NY 10038
 Phone: (516) 422-4133
 eMail: [EMAIL PROTECTED]
 http://matrix.csis.pace.edu/~vmakarov/

***


The information contained in this email message and any files
transmitted with it are confidential and intended solely for the use
by the individual(s) originally addressed. Please disregard and delete
this email if you are not the intended recipient.


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