0

複数の VSS プロットを 1 つのウィンドウで比較してみました。ただし、通常の手順でpar(mfrow=c(x,y)は機能しないようです。どちらもありませんlayout(matrix(c(1,2,3,4), 2, 2, byrow = TRUE))。次の例は、William Revelle の Web サイトです。プロット コマンドを変更する必要がありました。例は更新されていませんが、ある段階でからplotVSSに変更された可能性があります。VSS.plot

require(psych)
meanloading=.7
ncases=400
par(mfrow=c(2,4))

for (i in 1:4) 
{ x=VSS(VSS.simulate(ncases,36,i,meanloading),rotate="none")
VSS.plot(x,paste(i, " factor no rotation")) }

for (i in 1:4) 
{ x=VSS(VSS.simulate(ncases,36,i,meanloading),rotate="varimax")
VSS.plot(x,paste(i, " factor varimax rotation")) }

ウィンドウに複数のプロットが表示されない理由はありますか?

4

1 に答える 1

0

関数VSSplot引数なしで呼び出されます。したがって、デフォルトのTRUEが使用されます。これにより、 で生成されたプロットがリセットされますVSS.plot。で呼び出す必要がVSSありplot = FALSEます。

2 番目の問題は、関数VSS.plot自体です。を呼び出すparため、すべてのプロットがプロット フレームの同じ場所に表示されます。

関数から最初と最後の行を削除するとVSS.plot、すべてが正常に機能します。変更されたバージョンのコードは、VSS.plot2私の回答の最後にあります。

require(psych)
meanloading <- .7
ncases <- 400
par(mfrow=c(2,4))

for (i in 1:4) { 
  x <-VSS(VSS.simulate(ncases,36,i,meanloading),rotate="none", plot = FALSE)
  VSS.plot2(x,paste(i, " factor no rotation"))
}

for (i in 1:4) { 
  x <- VSS(VSS.simulate(ncases,36,i,meanloading),rotate="varimax", plot = FALSE)
  VSS.plot2(x,paste(i, " factor varimax rotation")) 
}

ここに画像の説明を入力


の修正版VSS.plot:

VSS.plot2 <- function (x, title = "Very Simple Structure", line = FALSE) 
{
    #op <- par(no.readonly = TRUE)
    n = dim(x)
    symb = c(49, 50, 51, 52)
    plot(x$cfit.1, ylim = c(0, 1), type = "b", 
         ylab = "Very Simple Structure Fit", 
         xlab = "Number of Factors", pch = 49)
    if (line) 
        lines(x$fit)
    title(main = title)
    x$cfit.2[1] <- NA
    x$cfit.3[1] <- NA
    x$cfit.3[2] <- NA
    x$cfit.4[1] <- NA
    x$cfit.4[2] <- NA
    x$cfit.4[3] <- NA
    lines(x$cfit.2)
    points(x$cfit.2, pch = 50)
    lines(x$cfit.3)
    points(x$cfit.3, pch = symb[3])
    lines(x$cfit.4)
    points(x$cfit.4, pch = symb[4])
    #par(op)
}
于 2014-01-23T15:54:30.017 に答える