[R] R-help Digest, Vol 274, Issue 1

Leo Mada |eo@m@d@ @end|ng |rom @yon|c@eu
Sat Dec 13 15:53:14 CET 2025


Dear R-Users,

1. I was finally able to get the colours to work properly. The solution is based on Vaclav's and Deepayan's suggestions. I have included the code for anyone interested.

library(lattice)
library(nlme)

panel.col = function (x, y, subscripts, groups, ...)
{
      panel.grid()
      panel.xyplot(x, y, ..., groups = groups, subscripts = subscripts)
      panel.superpose(x, y, subscripts, groups, type = "l")
}

tmp = plot(BodyWeight, innerGroups = ~ Diet)
tmp$panel = panel.col
tmp


2. Modify Text Size
I also wanted to generate some images for a presentation. I wanted to increase the text size so that relevant text becomes easy to read. After many failed attempts, I found it easier to modify the resulting trellis-object.

The code is rather hacky. For anyone interested, see function setCEX on GitHub:
https://github.com/discoleo/R/blob/master/Stat/Models.MixedEffects.R

I may try to improve it - when I have a little bit more spare time.

Sincerely,

Leonard

________________________________
From: R-help <r-help-bounces using r-project.org> on behalf of r-help-request using r-project.org <r-help-request using r-project.org>
Sent: Tuesday, December 2, 2025 1:00 PM
To: r-help using r-project.org <r-help using r-project.org>
Subject: R-help Digest, Vol 274, Issue 1

Send R-help mailing list submissions to
        r-help using r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
        r-help-request using r-project.org

You can reach the person managing the list at
        r-help-owner using r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."


Today's Topics:

   1. lme: Plot colours based on variable? (Leo Mada)

----------------------------------------------------------------------

Message: 1
Date: Tue, 2 Dec 2025 08:39:09 +0000
From: Leo Mada <leo.mada using syonic.eu>
To: Leo Mada via R-help <r-help using r-project.org>
Subject: [R] lme: Plot colours based on variable?
Message-ID:
        <DBAP192MB0956E139BFF599808E8BEA7784D8A using DBAP192MB0956.EURP192.PROD.OUTLOOK.COM>

Content-Type: text/plain; charset="utf-8"

Dear R-Users,

Is there a quick solution to plot colours based on a variable?

I tried something like this:

library(nlme)

plot(BodyWeight)

# Does NOT work!
colDiet = c(2:4)[BodyWeight$Diet]
plot(BodyWeight, col = colDiet)

# Wastes space
rat.fit = lme(weight ~ Time + Diet, data = BodyWeight, random = ~ Time|Rat)
plot(rat.fit, weight ~ Time | Rat + Diet)

Is there a quick way to base the colour on the Diet variable?

Many thanks,

Leonard


        [[alternative HTML version deleted]]




------------------------------

Subject: Digest Footer

_______________________________________________
R-help using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


------------------------------

End of R-help Digest, Vol 274, Issue 1
**************************************

	[[alternative HTML version deleted]]



More information about the R-help mailing list