[Rd] digits in summary.default

2006-09-14 Thread Simone Giannerini
Dear all,

the number of significant digits in summary default is

digits = max(3, getOption("digits") -  3)

on my platform this results to be 4. The point is that if you have,
say, integer data of magnitude greater than 10^3 the command summary
will produce heavily rounded results.
A simple example follow:

> x <- c(123456,234567,345678)

> x
[1] 123456 234567 345678

> summary(x)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
 123500  179000  234600  234600  290100  345700

# quite different from

> quantile(x)
  0%  25%  50%  75% 100%
123456.0 179011.5 234567.0 290122.5 345678.0

Is it  possible to adapt the number of significant digits to the
magnitude of the data?
The first thing that comes into my mind is
digits = nchar(trunc(max(x)))   #

If it is not possible then I think it would be nice to mention the
issue in the documentation.

Thanks for the attention,

Simone

> R.version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)

> Sys.getlocale()
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
>

__

Simone Giannerini
Dipartimento di Scienze Statistiche "Paolo Fortunati"
Universita' di Bologna
Via delle belle arti 41 - 40126  Bologna,  ITALY
Tel: +39 051 2098262  Fax: +39 051 232153

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


[Rd] changes in upcoming lattice

2006-09-14 Thread Deepayan Sarkar
Hi,

there will be some fairly major changes in the lattice that will get
released with R 2.4.0. A first version is now available on CRAN, at

http://cran.r-project.org/src/contrib/2.4.0/Recommended/lattice_0.14-3.tar.gz

Although there is a dependency on R 2.4, the package passes R CMD
check on 2.3.1 as well if you change the Depends line in DESCRIPTION.
In other words, you should be able to test it even if you are not
running r-devel.

There are 3 types of changes:

1. Some new features. These are of the most interest in the long run
(albeit to a very small number of users) , but they have not been
thoroughly tested or documented (and some features not even
implemented). Documentation, such as it is, can be found in

?axis.default
?packet.panel.default
?panel.number

2. Bugs that have been introduced in the course of implementing these
new features. Of course I'm hoping that there aren't any such, but I'm
sure there are. So testing your lattice code to flesh out these bugs
before the 2.4.0 release would be appreciated.

3. This is where I might get some legitimate complaints. For the last
several versions of lattice, there has been a feature where the panel
function would get passed arguments called panel.number and
packet.number under certain circumstances. This was to enable the
panel function to know which panel was being plotted. This was
intended as a quick hack, but apparently several users have found the
feature useful. Some new functions, described in ?panel.number,
address this issue in a cleaner and more general way.

Given these new functions, I would like to remove the earlier features
(arguments to panel functions). In fact, I have removed them in
lattice_0.14-3. I will put them back if other packages on CRAN start
to fail or if enough users want it back. I would normally have kept it
in with some sort of warning, but the formal deprecation mechanism
doesn't work in this setting, and I would rather start cleaning up
code that made this work than make it even more complicated. I would
be happy to assist package developers who want to write portable code
that works in both older and newer versions of lattice.

Comments / suggestions / bug reports are welcome.

Deepayan

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


[Rd] Legend Title missing (PR#9226)

2006-09-14 Thread mok2
Full_Name: Mark O. Kimball
Version: 2.1
OS: Linux
Submission from: (NULL) (128.253.11.148)


When log="x" is used in a plot() function, the legend "title" option creates
room for the text but does not display it. When the log="x" function is
disabled, the text is again displayed. The symbols and/or lines and legend text
is not affected.

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


Re: [Rd] Legend Title missing (PR#9226)

2006-09-14 Thread mschwartz
On Thu, 2006-09-14 at 20:35 +0200, [EMAIL PROTECTED]
wrote:
> Full_Name: Mark O. Kimball
> Version: 2.1
> OS: Linux
> Submission from: (NULL) (128.253.11.148)
> 
> 
> When log="x" is used in a plot() function, the legend "title" option creates
> room for the text but does not display it. When the log="x" function is
> disabled, the text is again displayed. The symbols and/or lines and legend 
> text
> is not affected.

>From NEWS for R 2.3.1:

 o  legend() with log axes would place the title in the wrong place.

Upgrade to the current version.

Please don't report bugs on obsolete versions.

HTH,

Marc Schwartz

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


[Rd] Question about substitute() and function def

2006-09-14 Thread Seth Falcon
Hi,

Can someone help me understand why

  substitute(function(a) a + 1, list(a=quote(foo)))

gives

  function(a) foo + 1

and not

  function(foo) foo + 1

The man page leads me to believe this is related to lazy evaluation of
function arguments, but I'm not getting the big picture.

Thanks,

+ seth


Using R 2.4 alpha svn r39255

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


Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Duncan Murdoch
On 9/14/2006 3:01 PM, Seth Falcon wrote:
> Hi,
> 
> Can someone help me understand why
> 
>   substitute(function(a) a + 1, list(a=quote(foo)))
> 
> gives
> 
>   function(a) foo + 1
> 
> and not
> 
>   function(foo) foo + 1
> 
> The man page leads me to believe this is related to lazy evaluation of
> function arguments, but I'm not getting the big picture.

I think it's the same reason that this happens:

 > substitute(c( a = 1, b = a), list(a = quote(foo)))
c(a = 1, b = foo)

The "a" in function(a) is the name of the arg, it's not the arg itself 
(which is missing).  Now a harder question to answer is why this happens:

 > substitute(function(a=a) 1, list(a=quote(foo)))
function(a = a) 1

I would have expected to get "function(a = foo) 1".

Duncan Murdoch

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


Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Bill Dunlap
On Thu, 14 Sep 2006, Duncan Murdoch wrote:

> I think it's the same reason that this happens:
>
>  > substitute(c( a = 1, b = a), list(a = quote(foo)))
> c(a = 1, b = foo)
>
> The "a" in function(a) is the name of the arg, it's not the arg itself
> (which is missing).  Now a harder question to answer is why this happens:
>
>  > substitute(function(a=a) 1, list(a=quote(foo)))
> function(a = a) 1
>
> I would have expected to get "function(a = foo) 1".

In Splus you do get what you expected.
   > substitute(function(a=a) 1, list(a=quote(foo)))
   function(a = foo)
   1
   > substitute(function(a=func(100))func(a), list(func=quote(myFunction)))
   function(a = myFunction(100))
   myFunction(a)

R's substitute does not appear to go into
the 'formals' of a function definition
when looking for names to replace.


Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."

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


Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Robert Gentleman


Duncan Murdoch wrote:
> On 9/14/2006 3:01 PM, Seth Falcon wrote:
>> Hi,
>>
>> Can someone help me understand why
>>
>>   substitute(function(a) a + 1, list(a=quote(foo)))
>>
>> gives
>>
>>   function(a) foo + 1
>>
>> and not
>>
>>   function(foo) foo + 1
>>
>> The man page leads me to believe this is related to lazy evaluation of
>> function arguments, but I'm not getting the big picture.
> 
> I think it's the same reason that this happens:
> 
>  > substitute(c( a = 1, b = a), list(a = quote(foo)))
> c(a = 1, b = foo)
> 
> The "a" in function(a) is the name of the arg, it's not the arg itself 

yes, but the logic seems to be broken. In Seth's case there seems to be 
no way to use substitute to globally change an argument and all 
instances throughout a function, which seems like a task that would be 
useful.

even here, I would have expected all instances of a to change, not some

> (which is missing).  Now a harder question to answer is why this happens:
> 
>  > substitute(function(a=a) 1, list(a=quote(foo)))
> function(a = a) 1

   a bug for sure


> I would have expected to get "function(a = foo) 1".
> 
> Duncan Murdoch
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
PO Box 19024
Seattle, Washington 98109-1024
206-667-7700
[EMAIL PROTECTED]

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


[Rd] Evaluating R expresions from C

2006-09-14 Thread Patricia Bautista
Good afternood everybody,

I have a question about using "Rinternals.h": If I
need to evaluate a R expresion from my c++ code Do I
have to change my c++ code enterelly?, I'm thinking
about the way I allocate memory and the way I print
for example.

Thanks for any help in advance.
Patricia






___ 
Do You Yahoo!? 
La mejor conexión a Internet y 2GB extra a tu correo por $100 al mes. 
http://net.yahoo.com.mx

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


Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Bill Dunlap
On Thu, 14 Sep 2006, Robert Gentleman wrote:

> >  > substitute(c( a = 1, b = a), list(a = quote(foo)))
> > c(a = 1, b = foo)
> >
> > The "a" in function(a) is the name of the arg, it's not the arg itself
>
> yes, but the logic seems to be broken. In Seth's case there seems to be
> no way to use substitute to globally change an argument and all
> instances throughout a function, which seems like a task that would be
> useful.
>
> even here, I would have expected all instances of a to change, not some

In Splus, substitute changes all "name" objects with
the values given by the names on the list given as its
second argument.  In Splus the argument name
in the formals list is not of class "name" - it is
of class "character".  Hence it is not substituted.
I agree it would be handy if it were substituted.

In R I'm not sure what class/mode the argument name
in the formals list has.  The formals list is a "pairlist"
and the argument names are th names of the pairlist.
What internal class/mode do they have?

However, substitute() in R does not appear to go into
formal arguments of a function at all.


Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."

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


Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Duncan Murdoch
On 9/14/2006 3:49 PM, Robert Gentleman wrote:
> 
> Duncan Murdoch wrote:
>> On 9/14/2006 3:01 PM, Seth Falcon wrote:
>>> Hi,
>>>
>>> Can someone help me understand why
>>>
>>>   substitute(function(a) a + 1, list(a=quote(foo)))
>>>
>>> gives
>>>
>>>   function(a) foo + 1
>>>
>>> and not
>>>
>>>   function(foo) foo + 1
>>>
>>> The man page leads me to believe this is related to lazy evaluation of
>>> function arguments, but I'm not getting the big picture.
>> I think it's the same reason that this happens:
>>
>>  > substitute(c( a = 1, b = a), list(a = quote(foo)))
>> c(a = 1, b = foo)
>>
>> The "a" in function(a) is the name of the arg, it's not the arg itself 
> 
> yes, but the logic seems to be broken. In Seth's case there seems to be 
> no way to use substitute to globally change an argument and all 
> instances throughout a function, which seems like a task that would be 
> useful.

I think variables and argument names are fundamentally different things, 
so I don't see this as very surprising.  It should take two steps to 
make a change like that.  Use substitute() to change the variables, put 
the result in f, change the names of the formals using

names(formals(f)) <- "foo".

I'm not sure if there's a simple way to change the first "a" in the 
expression c(a=1, b=a), but there are probably convoluted ways to do it.

> 
> even here, I would have expected all instances of a to change, not some
> 
>> (which is missing).  Now a harder question to answer is why this happens:
>>
>>  > substitute(function(a=a) 1, list(a=quote(foo)))
>> function(a = a) 1
> 
>a bug for sure

Yes.

Duncan

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