我想创建一个仅包含文本文件中特征的前 10 个值的点图。以下代码有效,但输出是包含所有 160 个变量的点图。
library(lattice)
table<-"imp_s2.txt"
DT<-read.table(table, header=T)
# output graph to pdf file
pdf("dotplot_s2.pdf")
colnames(DT)
DT$feature <- reorder(DT$feature, DT$IncMSE)
dotplot(feature ~ IncMSE, data = DT,
aspect = 1.5,
xlab = "Variable Importance, Scale 2",
scales = list(cex = .6),
panel = function (x, y) {
panel.abline(h = as.numeric(y), col = "gray", lty = 2)
panel.xyplot(x, as.numeric(y), col = "black", pch = 16)})
dev.off()