[R] lattice: how to use a log scale on the x-axis with the bwplot function
Laurent Rhelp
L@urentRHe|p @end|ng |rom |ree@|r
Sat Dec 10 15:15:56 CET 2022
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(100000,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
More information about the R-help
mailing list