[R] Several quick questions

Sébastien pomchip at free.fr
Mon Jul 9 15:53:55 CEST 2007


Thanks all of you guys for your help. It will most helpful.


deepayan.sarkar at gmail.com a écrit :
> On 7/7/07, Sébastien <pomchip at free.fr> wrote:
>> Dear R users,
>>
>> Here is a couple a quick questions, for which I was unable to not find
>> any answer in the list archives and in the help:
>
> [...]
>
>> 2- When a log scale is called in a graph, the label takes a format like
>> 10^n.
>
> That's true for lattice, but not traditional graphics, as far as I know.
>
>> Is there a way to come back to a regular number format like 1, 10,
>> 100... without having to create a custom axis ?
>
> Depends on what you mean by "custom axis". You don't need to manually
> choose the tick positions etc, but you still need to define the rules
> that determine how they are calculated. See example(axis.default) for
> an example where the tick positions remain the same (as the defaults),
> but the labels change.  The slightly different rule used in
> traditional graphics is available through the axTicks() function,
> which basically boils down to this:
>
> logTicks <- function (lim, loc = c(1, 5))
> {
>    ii <- floor(log10(range(lim))) + c(-1, 2)
>    main <- 10^(ii[1]:ii[2])
>    r <- as.numeric(outer(loc, main, "*"))
>    r[lim[1] <= r & r <= lim[2]]
> }
>
> where 'lim' is the limits in the original scale. So we have
>
>> logTicks(c(1, 100))
> [1]   1   5  10  50 100
>> logTicks(c(1, 100), loc = c(2, 5, 10))
> [1]   1   2   5  10  20  50 100
>
>> 3- In lattice graphics, how does the default value of the "axs" argument
>> influence the values of "limits" ?
>> This question should be considered in the following context. The help
>> states that a 4% extension is applied by default to the axis range in
>> base graphics. So, I have tried to apply this 4 % extension to create
>> some custom lattice graphics. I worked on a dataset in which the
>> independent variable ranged from 0  to 120, so I basically customized my
>> axis using limits=c(-4.8,124.8). The results of the graphics with and
>> without the limits command were not identical...
>
> The extension is user-settable in lattice, and defaults to 7% (I think
> this value came from Trellis specs, but I don't remember the exact
> details).
>
>> lattice.getOption("axis.padding")
> $numeric
> [1] 0.07
>
> $factor
> [1] 0.6
>
> -Deepayan



More information about the R-help mailing list