5

在 Excel 中,数据组织如下:

                                              Bare NP                   Singular-Marked NP               Plural-Marked NP   
                                    BrP Speakers    AmE Speakers    BrP Speakers    AmE Speakers    BrP Speakers AmE Speakers
Plural Interpretation               0.005747126 0.006896552         0.194117647 0.124567474         0.872093023 0.985815603
Plural & Singular Interpretation    0.649425287 0.910344828         0.029411765 0.051903114         0.127906977 0.014184397
Singular Interpretation             0.344827586 0.082758621         0.776470588 0.823529412         0           0

我能够生成如下所示的堆叠条形图:

在此处输入图像描述

有没有一种简单的方法来重现将 x 轴划分为单独条件(“Bare NP”、“Singular-Marked NP”和“Plural-Marked NP”)的方式R

目前我能想到的只有这个:

pluralInterp <- c(0.005747126,0.006896552,0.194117647,0.124567474,0.872093023,0.985815603)

pluralAndSingInterp <- c(0.649425287,0.910344828,0.029411765,0.051903114,0.127906977,0.014184397)

singInterp <- c(0.344827586,0.082758621,0.776470588,0.823529412,0,0)

a  <- rbind(pluralInterp,pluralAndSingInterp,singInterp)

colnames(a) <- c("Bare NP ~ BrP Speakers",
                 "Bare NP ~ AmE Speakers",
                 "Singular-Marked NP ~ BrP Speakers",
                 "Singular-Marked NP ~ AmE Speakers",
                 "Plural-Marked NP ~ BrP Speakers",
                 "Plural-Marked NP ~ AmE Speakers"
                 )

barplot(a,
        col=c("blue","red","purple"),
        ylab="Frequency of Interpretation",
        xlab="Form of NP and Native Language",
        main="Frequency of BrP and AmE Interpretations of NPs in Neutral Environments"
        )

这会产生以下图表:

在此处输入图像描述

4

1 回答 1

4

对利润进行一点手动调整并跟注axis()两次可以让你到达那里。保存条形图就像bp <- barplot(...)保存每个条的中点以供将来参考。

oldpar <-par(mar=c(7,5.1,4.1,2.1))

bp <- barplot(a,
        col=c("blue","red","purple"),
        ylab="Frequency of Interpretation",
        xlab="",
        main="Frequency of BrP and AmE Interpretations \n of NPs in Neutral Environments",
        axisnames=FALSE
       )

然后,您可以使用存储的值bp来正确对齐事物。line=...您可以使用参数对齐组和子组标签axis()

avgpts <- tapply(bp,rep(1:3,each=2),mean)
grps <- c("Bare NP","Singular-Marked NP","Plural-Marked NP")
subgrps <- c("BrP","AmE")
axis(1,at=bp,labels=rep(subgrps,3), cex.axis=0.7)
axis(1,at=avgpts,labels=grps, cex.axis=0.7,line=1.5,lwd=0)

title(xlab="Form of NP and Native Language",line=4.5)

导致:

在此处输入图像描述

于 2013-09-13T00:37:27.437 回答