我是r的新手,正在努力创建具有以下功能的图(以测试线性和正态分布假设)。当我运行这些功能时,我在控制台中得到了正确的结果,但是该图根本没有出现在“图”中/或者没有显示标签。
random = rchisq(nrow(vdata_clean1), 7)
fake = lm(random~., data = vdata_clean1)
standardized = rstudent(fake)
qqnorm(standardized)
abline(0,1)
(或)
qqnorm(standardized, main = "Normal Q-Q Plot", xlab = "Theoretical
Quantiles", ylab = "Sample Quantiles", plot.it = TRUE, datax = FALSE,
distribution)
mvn(vdata_clean1, mvnTest = c("mardia"),
covariance = TRUE, tol = 1e-25, alpha = 0.5, scale = FALSE,
desc = TRUE, transform = "none", R = 1000, univariateTest = c("SW"),
univariatePlot = c("qq"), multivariatePlot = c("qqplot"),
multivariateOutlierMethod = "none", bc = FALSE, bcType = "rounded",
showOutliers = FALSE, showNewData = FALSE)
这些是我安装的软件包:
install.packages("lavaan")
library(lavaan)
install.packages("semPlot")
library(semPlot)
install.packages("semTools")
library(semTools)
install.packages("MVN")
library(MVN)
install.packages("mvtnorm")
library(mvtnorm)
install.packages("ggplot2")
library(ggplot2)
install.packages("qgraph")
library(qgraph)
install.packages("GGally")
library(GGally)
这是我的数据示例:
head(vdata_clean1) 小标题:6 x 15 ILproto_1 ILproto_2 ILproto_3 ILproto_4 ILadvance_1 ILadvance_2
ILadvance_3 ILadvance_4 ILentre_1 ILentre_2
1 2 [2] 2 [2] 6 [6] 2 [2] 2 [2] 2 [2] 2 [2]
2 [2] 2 [2] 2 [2] 2 5 [5] 5 [5] 5 [5] 5 [5] 5 [5] 4 [4] 6 [6]
4 [4] 5 [5] 5 [5] 3 6 [6] 5 [5] 5 [5] 6 [6] 5 [5] 4 [4] 5 [5]
6 [6] 6 [6] 5 [5] 4 2 [2] 3 [3] 4 [4] 5 [5] 5 [5] 6 [6] 7
[强... 6 [6] 4 [4] 5 [5] 5 3 [3] 5 [5] 4 [4] 5 [5] 3 [3] 5 [5] 5 [5]
3 [3] 3 [3] 4 [4] 6 7 [Stron…4 [4] 5 [5] 4 [4] 5 [5] 3 [3] 5 [5]
3 [3] 5 [5] 3 [3] #…还有5个变量:ILentre_3,ILentre_4,
ILimpres_1,ILimpres_2, #ILimpres_3
> dput(vdata_clean1)
structure(list(ILproto_1 = structure(c(2, 5, 6, 2, 3, 7, 1, 5,
4, 6, 4, 3, 5, 1, 7, 4, 4, 4, 2, 4, 4, 5, 2, 6, 6, 6, 7, 4, 4,
4, 4, 5, 4, 6, 6, 3, 4, 7, 5, 1, 6, 6, 2, 3, 5, 7, 5, 3, 7, 6,
6, 7, 7, 7, 4, 5, 4, 4, 7, 5, 5, 6, 5, 6, 6, 5, 7, 5, 3, 4, 5,
4, 7, 3, 6, 7, 4, 7, 5, 5, 7, 5, 4, 7, 2, 7, 6, 7, 3, 6, 7, 5,
5, 7, 3, 6, 6, 6, 7, 5), label = "ILproto_1", format.spss = "F40.0",
display_width = 12L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)),
ILproto_2 = structure(c(2, 5, 5, 3, 5, 4, 1, 6, 4, 7, 4, 2, 4, 1, 7, 4,
4, 5, 2, 4, 4, 5, 2, 6, 6, 6, 7, 4, 4, 4, 4, 5,
4, 5, 6, 3, 5, 7, 4, 1, 6, 6, 2, 1, 5, 7, 5, 3, 7, 6, 6, 7, 7,
7, 3, 5, 4, 4, 7, 5, 5, 6, 5, 6, 6, 4, 7, 5, 4, 4, 5, 3, 7, 3,
7, 6, 4, 7, 5, 5, 6, 5, 4, 7, 2, 7, 6, 7, 3, 6, 7, 5, 5, 7, 3,
6, 6, 5, 7, 5), label = "ILproto_2", format.spss = "F40.0",
display_width = 11L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)),
ILproto_3 = structure(c(6, 5, 5, 4, 4, 5, 1, 6, 5, 7, 4,
3, 4, 1, 7, 4, 4, 5, 3, 4, 4, 5, 2, 6, 4, 6, 7, 4, 5, 4, 3, 4,
4, 6, 6, 3, 4, 7, 5, 1, 6, 6, 5, 2, 6, 7, 6, 4, 7, 6, 6, 7, 7,
5, 3, 6, 4, 4, 7, 5, 5, 6, 5, 6, 6, 6, 7, 6, 3, 4, 5, 4, 7, 3,
7, 7, 4, 7, 4, 5, 5, 5, 7, 7, 2, 7, 6, 7, 4, 6, 7, 7, 5, 7, 3,
6, 6, 6, 7, 5), label = "ILproto_3", format.spss = "F40.0", class =
"haven_labelled", labels = c(`Strongly disagree
1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly agree
7` = 7)), ILproto_4 = structure(c(2, 5, 6, 5, 5, 4, 1, 5, 5, 7, 4, 1,
5, 1, 7, 5, 4, 5, 2, 4, 4, 5, 2, 6, 5, 6, 7, 4, 4, 5, 5, 4,
4, 6, 6, 3, 4, 7, 5, 1, 6, 6, 2, 2, 6, 7, 7, 5, 7, 6, 6, 7, 7,
5, 4, 6, 4, 4, 7, 5, 5, 6, 4, 6, 6, 5, 7, 6, 5, 5, 5, 3, 7, 3,
5, 6, 5, 7, 4, 5, 4, 5, 7, 7, 2, 7, 6, 7, 3, 6, 7, 5, 5, 7, 3,
6, 6, 5, 7, 6), label = "ILproto_4", format.spss = "F40.0",
display_width = 10L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)), ILadvance_1 = structure(c(2, 5, 5, 5, 3, 5, 3, 6, 4, 7,
2, 4, 6, 1, 7, 4, 4, 4, 3, 4, 4, 6, 2, 5, 6, 6, 5, 4, 4, 4, 4, 6,
4, 6, 6, 4, 4, 7, 5, 1, 6, 6, 2, 2, 5, 7, 7, 7, 7, 6, 6, 6, 7,
1, 4, 6, 4, 2, 7, 2, 6, 6, 7, 6, 6, 3, 7, 6, 4, 4, 5, 4, 7, 3,
7, 7, 5, 7, 4, 6, 4, 5, 7, 7, 2, 7, 7, 7, 5, 7, 7, 7, 5, 7, 4,
5, 7, 6, 7, 4), label = "Iladvance_1", format.spss = "F40.0",
display_width = 11L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)),
ILadvance_2 = structure(c(2, 4, 4, 6, 5, 3, 4, 6, 5, 7, 4,
2, 4, 1, 7, 4, 4, 4, 3, 4, 4, 6, 2, 5, 6, 6, 5, 4, 4, 3, 4, 4,
4, 6, 6, 5, 4, 7, 6, 1, 6, 6, 2, 2, 6, 7, 6, 6, 7, 6, 6, 6, 7,
1, 5, 6, 4, 4, 7, 4, 6, 6, 7, 6, 6, 4, 7, 6, 4, 4, 5, 3, 7, 3,
6, 6, 4, 7, 4, 6, 2, 5, 7, 7, 2, 7, 7, 7, 5, 7, 7, 7, 4, 7, 4,
6, 7, 5, 7, 4), label = "Iladvance_2", format.spss = "F40.0",
display_width = 9L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)), ILadvance_3 = structure(c(2, 6, 5, 7, 5, 5, 4, 5, 5, 6,
4, 2, 4, 1, 7, 4, 4, 4, 3, 4, 4, 6, 2, 5, 6, 6, 5, 4, 4, 3, 4, 6,
4, 6, 6, 4, 4, 7, 5, 1, 6, 6, 4, 2, 5, 7, 7, 7, 7, 6, 6, 6, 7,
1, 4, 6, 4, 4, 7, 4, 6, 6, 7, 6, 6, 5, 7, 6, 5, 4, 5, 4, 7, 3,
7, 7, 4, 7, 5, 6, 3, 5, 7, 7, 2, 7, 7, 7, 5, 7, 7, 7, 6, 7, 4,
7, 7, 5, 7, 5), label = "Iladvance_3", format.spss = "F40.0",
display_width = 11L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)), ILadvance_4 = structure(c(2, 4, 6, 6, 3, 3, 4, 5, 4, 7,
4, 2, 4, 1, 7, 4, 4, 4, 3, 4, 4, 6, 2, 5, 6, 6, 5, 4, 4, 5, 3, 4,
4, 6, 6, 4, 4, 7, 5, 1, 6, 6, 4, 1, 6, 7, 7, 7, 7, 6, 6, 6, 7,
1, 4, 6, 4, 4, 7, 4, 6, 6, 7, 6, 7, 4, 7, 5, 5, 4, 5, 3, 7, 3,
7, 6, 5, 7, 5, 6, 4, 5, 7, 7, 2, 7, 7, 7, 5, 7, 7, 7, 6, 7, 4,
7, 7, 6, 7, 5), label = "Iladvance_4", format.spss = "F40.0",
display_width = 9L, class = "haven_labelled", labels = c(`Strongly
disagree 1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `Strongly
agree 7` = 7)), row.names = c(NA, -100L), class = c("tbl_df", "tbl",
"data.frame"))
....entre_1, entre_2, entre_3, entre_1, impres_1, impres_2_, impres_3
我非常感谢您对此提供的帮助:)