1

我正在尝试使用 error.bars 绘制具有标准偏差的均值,并且效果很好。我知道我也可以使用 ggplot 方法,但我无法为我的数据实现它......

到目前为止一切顺利,我现在遇到的问题是,并非 x 轴上的所有变量都被打印出来,实际上只是每秒左右打印一次。

在箱线图中,我可以使用命令names, las=2. error.bars 函数有类似的东西吗?我在手册中找不到任何内容。

这是我正在使用的代码:

psych:::error.bars(orderedcols,sd=TRUE,add=TRUE,arrow.len=0.05,bars=TRUE, xlab="Adjectives", ylab="Mean Intensity", main="Mean Intensities and Standard Deviations")

编辑:

dput(orderedcols) 结构(list(brilliant = c(50, 82, 80, 12, 80, 80, 85, 72, 80, 85, 65, 100, 90, 97, 85, 95, 100, 100), 巧妙= c(75, 70, 50, 79, 85, 80, 100, 50, 95, 90, 50, 100, 100, 1, 80, 83, 83, 100), 智能 = c(40, 70, 45, 87, 75, 60, 80, 42, 86, 80, 29, 100, 50, 45, 61, 77, 40, 90), 亮 = c(20, 60, 40, 58, 65, 50, 75, 40 , 77, 55, 50, 58, 50, 56, 76, 83, 30, 75), 智能 = c(30, 62, 25, 47, 45, 50, 50, 32, 54, 75, 27, 81, 70, 69, 40, 85, 29, 80), 聪明 = c(60, 66, 20, 52, 70, 60, 50, 20, 66, 35, 31, -9, -10, 44, 78, 91 , 50, 70), 愚蠢 = c(-15, -35, -20, -44, -30, -10, -20, -10, -32, -25, -27, -23, -10, - 15, -25, 43, -36, -10), daft = c(-10, -60, -30, -14, -20, -10, -77, 0, -90, -20, -36, -61, 10, 0, -33, -100, -21, -50 ), 暗淡 = c(-35, -62, -20, 8, -80, -30, -35,-24, -60, -35, -34, -9, -100, -34, -83, -71, -27, -20), 哑巴 = c(-25, -50, -60, -37, -40, -30, -25, -29, -76, -75, -78, -37, 0, -30, -39, -91, -38, -10),无意识 = c(-50, - 55, -60, -12, -30, -50, -25, 0, -62, -50, -100, -100, 0, -6, -39, -52, -59, -25),空= c(-20, -80, -30, -6, -35, -30, -90, -25, -50, -50, -38, -100, -75, -25, -12, -100 , -22, -10), 愚蠢 = c(-25, -80, -30, -75, -50, -40, -80, -28, -37, -75, -41, -50, -11 , -100, -51, -91, -36, -15),dimwitted = c(-50, -77, -20, -59, -40, -60, -66, -77, -45, -25 , -32, -77, -100, -46, -74, -89, -39, -30),白痴 = c(-60, -91, -50, -26, -60, -50, -83 , -41, -58, -80, 30, -86, -100, -46, -91, -89, -60, -40), moronic = c(-90, -87, -40, -19, -65、-60、-90、-85、-78、-75、-59、-100、-80、-22、-71、-95、-65、-15), 无脑 = c(-75, -85, -80, -55, -20, -100, -90, -35, -85, -90, -31, -100, -90, -73, -31, -63, -100, -95),白痴 = c(-100, -95, -75, 31, -50, -75, -90, -100, -72, -85, -63, - 98, -100, -33, -92, -90, -74, -100)), .Names = c("brilliant", "ingenious", "intelligent", "bright", "smart", "brainy" ,“愚蠢”,“愚蠢”,“昏暗”,“愚蠢”,“没有头脑”,“愚蠢”,“愚蠢”,“愚蠢”,“白痴”,“白痴”,“无脑”,“愚蠢”),类 = “data.frame”, row.names = c(2L, 4L, 5L, 6L, 7L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,21L)) 11 72 50 42 40 32 20 -10 0 -24 -29 0 -25 -28 -77 -41 -85 -35 -100 12 80 95 86 77 54 66 -32 -90 -60 -76 -62 - 50 -37 -45 -58 -78 -85 -72 13 85 90 80 55 75 35 -25 -20 -35 -75 -50 -50 -75 -25 -80 -75 -90 -85 14 65 50 29 50 27 31 -27 -36 -34 -78 -100 -38 -41 -32 30 -59 -31 -63 15 100 100 100 58 81 -9 -23 -61 -9 -37 -100 -100 -50 -77 -86 -100 -100 -98 16 90 100 50 50 70 -10 -10 10 -100 0 0-75 -11 -100 -100 -80 -90 -100 17 97 1 45 56 69 44 -15 0 -34 -30 -6 -25 -100 -46 -46 -22 -73 -33 18 85 80 61 76 40 78 -25 -33 -83 -39 -39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 - 95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 -59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 - 10 -25 -10 -15 -30 -40 -15 -95 -100-90 -100 17 97 1 45 56 69 44 -15 0 -34 -30 -6 -25 -100 -46 -46 -22 -73 -33 18 85 80 61 76 40 78 -25 -33 -83 -39 - 39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 -95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 -59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 - 40 -15 -95 -100-90 -100 17 97 1 45 56 69 44 -15 0 -34 -30 -6 -25 -100 -46 -46 -22 -73 -33 18 85 80 61 76 40 78 -25 -33 -83 -39 - 39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 -95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 -59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 - 40 -15 -95 -100-15 0 -34 -30 -6 -25 -100 -46 -46 -22 -73 -33 18 85 80 61 76 40 78 -25 -33 -83 -39 -39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 -95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 - 59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 -40 -15 -95 -100-15 0 -34 -30 -6 -25 -100 -46 -46 -22 -73 -33 18 85 80 61 76 40 78 -25 -33 -83 -39 -39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 -95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 - 59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 -40 -15 -95 -100-39 -39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 -95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 -59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 -40 -15 -95 -100-39 -39 -12 -51 -74 -91 -71 -31 -92 19 95 83 77 83 85 91 43 -100 -71 -91 -52 -100 -91 -89 -89 -95 -63 -90 20 100 83 40 30 29 50 -36 -21 -27 -38 -59 -22 -36 -39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 -40 -15 -95 -100-39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 -40 -15 -95 -100-39 -60 -65 -100 -74 21 100 100 90 75 80 70 -10 -50 -20 -10 -25 -10 -15 -30 -40 -15 -95 -100

PS 不能加照片,名气太小了。。

4

1 回答 1

2

我认为这实际上很简单:您所要做的就是在运行命令las之前设置图形参数:error.bars

par(las=2)
error.bars(orderedcols,sd=TRUE,add=TRUE,arrow.len=0.05,bars=TRUE,
           xlab="Adjectives", ylab="Mean Intensity",
           main="Mean Intensities and Standard Deviations")

一个ggplot2解决方案(你也可以旋转这个标签——在 StackOverflow 上搜索如何做——但我选择旋转整个图)

library("reshape2")
library("ggplot2")
theme_set(theme_bw())
ggplot(melt(orderedcols),aes(x=variable,y=value))+
    stat_summary(geom="bar",fun.y=mean,position="identity",fill="gray")+
    stat_summary(geom="errorbar",width=0.2,
                 fun.data=function(x) { data.frame(y=mean(x), 
                     ymin=mean(x)-sd(x),ymax=mean(x)+sd(x)) })+
    coord_flip()
于 2013-03-13T20:15:21.147 回答