gpt4 book ai didi

r - 如何在 R 的条形图中对 X 轴进行排序?

转载 作者:行者123 更新时间:2023-12-04 00:59:40 26 4
gpt4 key购买 nike

我的分箱数据如下所示:

  (8.048,18.05] (-21.95,-11.95] (-31.95,-21.95]   (18.05,28.05] (-41.95,-31.95]
81 76 18 18 12
(-132,-122] (-122,-112] (-112,-102] (-162,-152] (-102,-91.95]
6 6 6 5 5
(-91.95,-81.95] (-192,-182] (28.05,38.05] (38.05,48.05] (58.05,68.05]
5 4 4 4 4
(78.05,88.05] (98.05,108] (-562,-552] (-512,-502] (-482,-472]
4 4 3 3 3
(-452,-442] (-412,-402] (-282,-272] (-152,-142] (48.05,58.05]
3 3 3 3 3
(68.05,78.05] (118,128] (128,138] (-582,-572] (-552,-542]
3 3 3 2 2
(-532,-522] (-422,-412] (-392,-382] (-362,-352] (-262,-252]
2 2 2 2 2
(-252,-242] (-142,-132] (-81.95,-71.95] (148,158] (-1402,-1392]
2 2 2 2 1
(-1372,-1362] (-1342,-1332] (-942,-932] (-862,-852] (-822,-812]
1 1 1 1 1
(-712,-702] (-682,-672] (-672,-662] (-632,-622] (-542,-532]
1 1 1 1 1
(-502,-492] (-492,-482] (-472,-462] (-462,-452] (-442,-432]
1 1 1 1 1
(-432,-422] (-352,-342] (-332,-322] (-312,-302] (-302,-292]
1 1 1 1 1
(-202,-192] (-182,-172] (-172,-162] (-51.95,-41.95] (88.05,98.05]
1 1 1 1 1
(108,118] (158,168] (168,178] (178,188] (298,308]
1 1 1 1 1
(318,328] (328,338] (338,348] (368,378] (458,468]
1 1 1 1 1

我如何绘制这些数据,以便 bin 从左侧的最负值到右侧的最正值排序?目前我的图表看起来是like this .请注意,它根本没有排序。特别是第二个栏 (value = 76) 位于第一个栏的右侧:

 (8.048,18.05] (-21.95,-11.95]
81 76

这是我用来绘图的命令:

barplot(x,ylab="Number of Unique Tags", xlab="Expected - Observed")

最佳答案

我真的很想帮助回答您的问题,但我必须告诉您,我无法判断您的数据的正反面。我看到很多左括号但没有右括号。数据看起来按每行底部的值降序排列。我不知道如何使用“(8.048,18.05]”这样的值

我是否遗漏了一些明显的东西?您能否举一个更简单的示例,其中您的数据结构不是一个因素?

我通常希望数据框或矩阵有两列,一列用于 X,一列用于 Y。

看看这个排序示例是否有帮助(我在这里是在黑暗中拍摄)

tN <- table(Ni <- rpois(100, lambda=5))
r <- barplot(tN)

#stop here and examine the plot
#the next bit converts the matrix to a data frame,
# sorts it, and plots it again

df<-data.frame(tN)
df2<-df[order(df$Freq),]
barplot(df2$Freq)

关于r - 如何在 R 的条形图中对 X 轴进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/560329/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com