Created
December 22, 2022 05:19
-
-
Save ito4303/661f7eb33b28cd96272a30a3eed5aa5e to your computer and use it in GitHub Desktop.
An example to use glht function in the multcomp package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "R Notebook" | |
output: html_notebook | |
--- | |
## An example to use glht function in the multcomp package | |
```{r setup} | |
library(multcomp) | |
library(palmerpenguins) | |
``` | |
### View data | |
plot bill_length_mm vs. species | |
```{r} | |
png("plot01.png", width = 480, height = 480, pointsize = 14) | |
boxplot(bill_length_mm ~ species, data = penguins) | |
dev.off() | |
``` | |
### Multiple comparison | |
```{r} | |
bill_l.glht <- lm(bill_length_mm ~ species, data = penguins) |> | |
glht(linfct = mcp("species" = "Tukey")) | |
summary(bill_l.glht) | |
``` | |
### Plot the results | |
```{r} | |
png("plot02.png", width = 480, height = 520, pointsize = 14) | |
par(mai = c(1, 1, 1.25, 1)) | |
cld(bill_l.glht ) |> | |
plot() | |
dev.off() | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment