Я читаю книгу документации lme4, чтобы научиться анализировать линейные модели со смешанными эффектами.Я пытаюсь воспроизвести все шаги, но у меня возникает проблема при попытке построить переупорядоченный набор данных пенициллина, как это показано в разделе 8.2.2. Несколько случайных эффектов этого веб-сайта (http://www.john -ros.com / Rcourse /lme.html ) Ссылка на рисунок: http://www.john -ros.com / Rcourse / Rcourse_files / figure-html / figure-chunk-181-1.png
Пока чтоМне удалось изменить порядок фрейма данных и построить точки успешно с различными формами, но я не могу связать точки для каждого образца в правильном порядке.Они строят графики в первоначальном порядке, и сюжет выглядит действительно грязно.
Я пытался найти код для этого графика в Интернете, но я не могу найти его где-либо.Я заранее извиняюсь, если это тривиальный вопрос.
Здесь у вас есть код, который я написал до сих пор:
library(lme4)
require(lattice)
myPCH <- 1:6
myLTY <- 1:6
# Plotting only the dots in the right way
xyplot(reorder(plate, diameter) ~ diameter, Penicillin,
xlab="Diameter of growth inhibition zone (mm)",
ylab = "Plate",
groups=factor(sample,labels=as.character(unique(Penicillin$sample))),
pch=myPCH, col=1:6,
key = list(columns=6,
text = list(as.character(unique(Penicillin$sample))),
points = list(pch=myPCH, col=1:6)),
type = c("g","p"))
# Adding the lines in the wrong order (Modified so that they have
# different styles
xyplot(reorder(plate, diameter) ~ diameter, data=Penicillin,
xlab="Diameter of growth inhibition zone (mm)",
ylab = "Plate",
groups=factor(sample,labels=as.character(unique(Penicillin$sample))),
pch=myPCH, col=1:6,
lty=myLTY,
key = list(columns=6,
text = list(as.character(unique(Penicillin$sample))),
points = list(pch=myPCH, col=1:6)),
type = c("g","p","l"))
# Trying to plot the dots and the lines separately with the
# "panel = function(x, y, groups,...)" lattice function
xyplot(reorder(plate, diameter) ~ diameter, data=Penicillin,
groups=factor(sample,labels=as.character(unique(Penicillin$sample))),
xlab="Diameter of growth inhibition zone (mm)",
ylab = "Plate",
key = list(columns=6,
text = list(as.character(unique(Penicillin$sample))),
points = list(pch=myPCH, col=1:6)),
panel = function(x, y, groups,...) {
panel.xyplot(x, y,
pch=myPCH, col=1:6,
type = c("g","p"));
panel.linejoin(x, y,
lty=myLTY, col=1:6,
type = c("g","l"))
})
sessionInfo()
Я хотел бы нарисовать, точки и линиис различными формами, как это показано на рисунке png, о котором я упоминал ранее.
Это мой sessionInfo ():
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MEMSS_0.9-2 lattice_0.20-38 ggplot2_3.1.0 lme4_1.1-19 Matrix_1.2-15
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 rstudioapi_0.9.0 magrittr_1.5 bindr_0.1.1 splines_3.5.1
[6] MASS_7.3-51.1 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.4-0 R6_2.3.0
[11] rlang_0.3.1 minqa_1.2.4 plyr_1.8.4 dplyr_0.7.8 tools_3.5.1
[16] grid_3.5.1 gtable_0.2.0 nlme_3.1-137 withr_2.1.2 lazyeval_0.2.1
[21] assertthat_0.2.0 tibble_2.0.1 crayon_1.3.4 bindrcpp_0.2.2 purrr_0.2.5
[26] nloptr_1.2.1 glue_1.3.0 labeling_0.3 compiler_3.5.1 pillar_1.3.1
[31] scales_1.0.0 pkgconfig_2.0.2
Большое спасибо за помощь,