Re: [R] lattice: how to use a log scale on the x-axis with the bwplot function

2022-12-10 Thread Bert Gunter
... and here's a version where the x variable is different than y. It's
basically the same.


set.seed(123)
y <- runif(40,min=0, max= 10)
x <- seq(0,10, length = 40)
## 5 equally spaced groups labeled by log10 of the center
## of the intervals
xrng <- range(x)
eps <- .0001*c(-1,1)*diff(xrng) ## see ?cut
xrng <-xrng + eps
delta <- diff(xrng)/5 # 5 = number of intervals
brks <- seq(xrng[1], xrng[2],length.out =6)
labs <- round(log10(brks[-1] - delta/2), 2) ## log10 (centers)
groups <- cut(x,breaks = brks, ordered_result = TRUE,
  labels = paste0('10^',labs))
# creating the dataframe for the lattice functions
DF <- data.frame( y = y, groups = groups)

bwplot( y ~ groups
, data=DF
, scales = list(
   y = list(log=T)
),
)

On Sat, Dec 10, 2022 at 10:20 AM Bert Gunter  wrote:

> If Deepayan's suggestion does not suit and especially *if* I understand
> what you want to do correctly, then it seems to me that it is
> straightforward to create the groups and group labels manually:
>
> ## in verbose detail to hopefully improve clarity
> set.seed(123)  ## for reprex
> y <- runif(40,min=0, max= 10)  ##*small* reprex
> ## cut y into 5 equally spaced groups labeled by log10 of the center
> ## of the intervals
> yrng <- range(y)
> eps <- .0001*c(-1,1)*diff(yrng) ## see ?cut
> yrng <-yrng + eps
> delta <- diff(yrng)/5 # 5 = number of intervals
> brks <- seq(yrng[1], yrng[2],length.out =6)
> labs <- round(log10(brks[-1] - delta/2), 2) ## log10 (centers)
> groups <- cut(y,breaks = brks,
>   labels = paste0('10^',labs))
> # creating the dataframe for the lattice functions
> DF <- data.frame( y = y, groups = groups)
>
> bwplot( y ~ groups
> , data=DF
> , scales = list(
>y = list(log=T)
> ),
> )
>
> ## Of course, ignore if I have misunderstood.
>
> Cheers,
> Bert
>
> On Sat, Dec 10, 2022 at 8:03 AM Deepayan Sarkar 
> wrote:
>
>> Log-scales for the "factor" variable in bwplot() is not allowed.
>>
>> You could, however, use the panel function panel.bwplot() with
>> xyplot(num ~ num). The potential problem with that is the box widths,
>> which panel.bwplot() will not know how to compute.
>>
>> See if the following gives you a reasonable starting point:
>>
>> DF <- within(DF, m <- tapply(y, groups, mean))
>> xyplot(y ~ m, DF, scales = list(log = TRUE),
>>panel = panel.bwplot, horizontal = FALSE,
>>box.width = .0001)
>>
>> Best,
>> -Deepayan
>>
>> On Sat, Dec 10, 2022 at 7:46 PM Laurent Rhelp 
>> wrote:
>> >
>> > Dear R-Help list,
>> >
>> > I would like to use bwplot from the lattice package with a log scale
>> > both on
>> > the x-axis and the y-axis but I do not know how to do that because I do
>> > not know
>> > how to change the factor x-axis in a numeric x-axis.
>> >
>> >   Here is my example:
>> >
>> >
>> > library(lattice)
>> >
>> > # the mock data
>> > y <- runif(10,min=0, max=500)
>> > x <- seq(0,500,length=length(y))
>> > # I cut the x variable to create a factor variable in order to calculate
>> > the boxes
>> > groups <- cut(x,10,ordered_result = TRUE)
>> > # creating the dataframe for the lattice functions
>> > DF <- data.frame( x= x , y = y, groups = groups)
>> >
>> >
>> > ## ok for xyplot
>> > xyplot(   y ~ x
>> >, data=DF
>> >, scales = list(
>> >  y = list(log=T)
>> >  , x = list(log=T)
>> >
>> >)
>> > )
>> >
>> > ## ok for bwplot with the log scale for the y-axis
>> > bwplot( y ~ groups
>> >, data=DF
>> >, scales = list(
>> >  y = list(log=T)
>> >  # , x = list(log=T)
>> >
>> >)
>> > )
>> >
>> >
>> >
>> > ## Non ok for bwplot with the log scale for the x-axis
>> > bwplot( y ~ groups
>> >  , data=DF
>> >  , scales = list(
>> >y = list(log=T)
>> >  , x = list(log=T)
>> >
>> >  )
>> > )
>> > which gives an error because the x-axis is a factor, I would like to
>> > replace it
>> > for the display by the meddle of every class for example and put a log
>> > scale on the x-axis.
>> >
>> > Thank you for your help
>> > Best regards
>> > Laurent
>> >
>> >
>> >
>> > --
>> > Cet e-mail a été vérifié par le logiciel antivirus d'Avast.
>> > www.avast.com
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version 

Re: [R] lattice: how to use a log scale on the x-axis with the bwplot function

2022-12-10 Thread Bert Gunter
If Deepayan's suggestion does not suit and especially *if* I understand
what you want to do correctly, then it seems to me that it is
straightforward to create the groups and group labels manually:

## in verbose detail to hopefully improve clarity
set.seed(123)  ## for reprex
y <- runif(40,min=0, max= 10)  ##*small* reprex
## cut y into 5 equally spaced groups labeled by log10 of the center
## of the intervals
yrng <- range(y)
eps <- .0001*c(-1,1)*diff(yrng) ## see ?cut
yrng <-yrng + eps
delta <- diff(yrng)/5 # 5 = number of intervals
brks <- seq(yrng[1], yrng[2],length.out =6)
labs <- round(log10(brks[-1] - delta/2), 2) ## log10 (centers)
groups <- cut(y,breaks = brks,
  labels = paste0('10^',labs))
# creating the dataframe for the lattice functions
DF <- data.frame( y = y, groups = groups)

bwplot( y ~ groups
, data=DF
, scales = list(
   y = list(log=T)
),
)

## Of course, ignore if I have misunderstood.

Cheers,
Bert

On Sat, Dec 10, 2022 at 8:03 AM Deepayan Sarkar 
wrote:

> Log-scales for the "factor" variable in bwplot() is not allowed.
>
> You could, however, use the panel function panel.bwplot() with
> xyplot(num ~ num). The potential problem with that is the box widths,
> which panel.bwplot() will not know how to compute.
>
> See if the following gives you a reasonable starting point:
>
> DF <- within(DF, m <- tapply(y, groups, mean))
> xyplot(y ~ m, DF, scales = list(log = TRUE),
>panel = panel.bwplot, horizontal = FALSE,
>box.width = .0001)
>
> Best,
> -Deepayan
>
> On Sat, Dec 10, 2022 at 7:46 PM Laurent Rhelp 
> wrote:
> >
> > Dear R-Help list,
> >
> > I would like to use bwplot from the lattice package with a log scale
> > both on
> > the x-axis and the y-axis but I do not know how to do that because I do
> > not know
> > how to change the factor x-axis in a numeric x-axis.
> >
> >   Here is my example:
> >
> >
> > library(lattice)
> >
> > # the mock data
> > y <- runif(10,min=0, max=500)
> > x <- seq(0,500,length=length(y))
> > # I cut the x variable to create a factor variable in order to calculate
> > the boxes
> > groups <- cut(x,10,ordered_result = TRUE)
> > # creating the dataframe for the lattice functions
> > DF <- data.frame( x= x , y = y, groups = groups)
> >
> >
> > ## ok for xyplot
> > xyplot(   y ~ x
> >, data=DF
> >, scales = list(
> >  y = list(log=T)
> >  , x = list(log=T)
> >
> >)
> > )
> >
> > ## ok for bwplot with the log scale for the y-axis
> > bwplot( y ~ groups
> >, data=DF
> >, scales = list(
> >  y = list(log=T)
> >  # , x = list(log=T)
> >
> >)
> > )
> >
> >
> >
> > ## Non ok for bwplot with the log scale for the x-axis
> > bwplot( y ~ groups
> >  , data=DF
> >  , scales = list(
> >y = list(log=T)
> >  , x = list(log=T)
> >
> >  )
> > )
> > which gives an error because the x-axis is a factor, I would like to
> > replace it
> > for the display by the meddle of every class for example and put a log
> > scale on the x-axis.
> >
> > Thank you for your help
> > Best regards
> > Laurent
> >
> >
> >
> > --
> > Cet e-mail a été vérifié par le logiciel antivirus d'Avast.
> > www.avast.com
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lattice: how to use a log scale on the x-axis with the bwplot function

2022-12-10 Thread Deepayan Sarkar
Log-scales for the "factor" variable in bwplot() is not allowed.

You could, however, use the panel function panel.bwplot() with
xyplot(num ~ num). The potential problem with that is the box widths,
which panel.bwplot() will not know how to compute.

See if the following gives you a reasonable starting point:

DF <- within(DF, m <- tapply(y, groups, mean))
xyplot(y ~ m, DF, scales = list(log = TRUE),
   panel = panel.bwplot, horizontal = FALSE,
   box.width = .0001)

Best,
-Deepayan

On Sat, Dec 10, 2022 at 7:46 PM Laurent Rhelp  wrote:
>
> Dear R-Help list,
>
> I would like to use bwplot from the lattice package with a log scale
> both on
> the x-axis and the y-axis but I do not know how to do that because I do
> not know
> how to change the factor x-axis in a numeric x-axis.
>
>   Here is my example:
>
>
> library(lattice)
>
> # the mock data
> y <- runif(10,min=0, max=500)
> x <- seq(0,500,length=length(y))
> # I cut the x variable to create a factor variable in order to calculate
> the boxes
> groups <- cut(x,10,ordered_result = TRUE)
> # creating the dataframe for the lattice functions
> DF <- data.frame( x= x , y = y, groups = groups)
>
>
> ## ok for xyplot
> xyplot(   y ~ x
>, data=DF
>, scales = list(
>  y = list(log=T)
>  , x = list(log=T)
>
>)
> )
>
> ## ok for bwplot with the log scale for the y-axis
> bwplot( y ~ groups
>, data=DF
>, scales = list(
>  y = list(log=T)
>  # , x = list(log=T)
>
>)
> )
>
>
>
> ## Non ok for bwplot with the log scale for the x-axis
> bwplot( y ~ groups
>  , data=DF
>  , scales = list(
>y = list(log=T)
>  , x = list(log=T)
>
>  )
> )
> which gives an error because the x-axis is a factor, I would like to
> replace it
> for the display by the meddle of every class for example and put a log
> scale on the x-axis.
>
> Thank you for your help
> Best regards
> Laurent
>
>
>
> --
> Cet e-mail a été vérifié par le logiciel antivirus d'Avast.
> www.avast.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] lattice: how to use a log scale on the x-axis with the bwplot function

2022-12-10 Thread Laurent Rhelp

Dear R-Help list,

   I would like to use bwplot from the lattice package with a log scale 
both on
the x-axis and the y-axis but I do not know how to do that because I do 
not know

how to change the factor x-axis in a numeric x-axis.

 Here is my example:


library(lattice)

# the mock data
y <- runif(10,min=0, max=500)
x <- seq(0,500,length=length(y))
# I cut the x variable to create a factor variable in order to calculate 
the boxes

groups <- cut(x,10,ordered_result = TRUE)
# creating the dataframe for the lattice functions
DF <- data.frame( x= x , y = y, groups = groups)


## ok for xyplot
xyplot(   y ~ x
  , data=DF
  , scales = list(
    y = list(log=T)
    , x = list(log=T)

  )
)

## ok for bwplot with the log scale for the y-axis
bwplot( y ~ groups
  , data=DF
  , scales = list(
    y = list(log=T)
    # , x = list(log=T)

  )
)



## Non ok for bwplot with the log scale for the x-axis
bwplot( y ~ groups
    , data=DF
    , scales = list(
  y = list(log=T)
    , x = list(log=T)

    )
)
which gives an error because the x-axis is a factor, I would like to 
replace it
for the display by the meddle of every class for example and put a log 
scale on the x-axis.


Thank you for your help
Best regards
Laurent



--
Cet e-mail a été vérifié par le logiciel antivirus d'Avast.
www.avast.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[ESS] Need help installing ess using M-x package-install-file

2022-12-10 Thread Naresh Gurbuxani via ESS-help
In my organization, IT security set up disables emacs package installation from 
package archives (e.g. MELPA) using M-x package-install.  Therefore, I am 
downloading package tar files from package archives, then using M-x 
package-install-file command.  This method has successfully installed several 
packages (e.g., auctex) on my computer.  But with ess, I have run into 
problems. 

Here are details.  I used tar file downloaded from MELPA stable archives.  Ess 
homepage also has zip files.  I do not know how to use them to install ess.  

My ess installation went without any error messages (although some files were 
skipped).   
> 
> M-x ess-version
> ess-version: 18.10.2 [] (loaded from 
> c:/Users/ngurbuxani/AppData/Roaming/.emacs.d/elpa/)
>  
But I cannot launch R inferior process. 

> M-x R
> Eager macro-expansion failure: (wrong-number-of-arguments (3 . 4) 2) [2 times]
> define-obsolete-function-alias: Wrong number of arguments: (3 . 4), 2

I am using emacs 28.2
>  
> M-x emacs-version
> GNU Emacs 28.2 (build 2, x86_64-w64-mingw32) of 2022-09-13
>  
This is my ess setup in int.el file. 
> ;; 
> ;; ESS settings
> ;;
> (defun then_R_operator_ess ()
> "R - %>% operator or 'then' pipe operator for ess mode"
> (interactive)
> (just-one-space 1)
> (insert "%>%")
> (reindent-then-newline-and-indent))
>  
> (defun then_R_operator ()
> "R - %>% operator or 'then pipe operator for inferior mode"
> (interactive)
> (insert " %>% "))  ;no need to go 
> to next line
> ;; Keyboard shortcuts for pipe operators do not work in terminal
> ;; Use M-x
>  
> (use-package ess
> :ensure t
> :defer t
> :config
> (require 'ess-r-mode)
> (load "ess-autoloads")
> ;; (setq-default inferior-R-program-name "Rterm")
> (setq-default inferior-R-program-name
>"c:/Program Files/Microsoft/R 
> Open/R-3.5.1/bin/x64/Rterm.exe")
> (define-key ess-mode-map "_" #'ess-insert-assign)
> (define-key inferior-ess-mode-map "_" #'ess-insert-assign)
> (define-key ess-mode-map (kbd "C->") 'then_R_operator_ess)
> (define-key inferior-ess-mode-map (kbd "C->") 'then_R_operator)
> (setq inferior-ess-r-help-command
>"help(\"%s\", help_type=\"text\")\n") ; display help in emacs
> (show-paren-mode)  ; show matching 
> parentheses
> (setq ess-eval-visibly 'nowait); emacs is available during command run
> )
> ;;
> ;; End ESS settings
> ;;

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help