Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 频率分布表和曲线_R_Plot - Fatal编程技术网

R 频率分布表和曲线

R 频率分布表和曲线,r,plot,R,Plot,我是R的新手。我想创建一个频率表和以下数据的正态频率分布曲线。这样做的最佳方式是什么 x1= 5,9,5,12,35,55,43,35,18,12,9,22,22,55,7,12 x2= 8,12,24,16,15,20,20,24,35,5,7,9,6,8,6,18,14,12,16,12,5,6,9,10,10,12,18,15,16 您的建议将不胜感激 x试试: x <- sample(1:10,30,TRUE) x [1] 10 9 2 5 4 9 2 10

我是R的新手。我想创建一个频率表和以下数据的正态频率分布曲线。这样做的最佳方式是什么

x1= 5,9,5,12,35,55,43,35,18,12,9,22,22,55,7,12
x2= 8,12,24,16,15,20,20,24,35,5,7,9,6,8,6,18,14,12,16,12,5,6,9,10,10,12,18,15,16  
您的建议将不胜感激

x试试:

x <- sample(1:10,30,TRUE)
x
 [1] 10  9  2  5  4  9  2 10  2  2  4  5  9  2 10  8  8  6  7  3  8  1  1  7  6  8  6  2  3  5
table(x)
x
 1  2  3  4  5  6  7  8  9 10 
 2  6  2  2  3  3  2  4  3  3 

plot(table(x),type = "l")

对于表格版本:

hh = hist(x2)
bb = hh$breaks

hh.breaks = as.character()
for(i in 2:length(bb)) {
    hh.breaks[i-1]=paste0(bb[i-1],'-',bb[i])
}
dd = data.frame(hh.breaks, hh$counts, hh$density, hh$mids)

dd

 hh.breaks hh.counts  hh.density hh.mids
1      5-10        12 0.082758621     7.5
2     10-15         7 0.048275862    12.5
3     15-20         7 0.048275862    17.5
4     20-25         2 0.013793103    22.5
5     25-30         0 0.000000000    27.5
6     30-35         1 0.006896552    32.5

您可能会发现此链接很有用:
如果你只是简单地搜索,还有很多其他问题。

@andrie我想,你误解了我的问题。我不需要条形图。我需要一条分布曲线。好的,我重新打开你的问题,让你有机会编辑和澄清。特别是,说明您的问题与所有其他有关频率分布的问题有何不同。解释你所说的分布曲线是什么意思,以及它与条形图有什么不同。密度图有很多位置,但频率表没有那么多。一个好的网站是:谢谢你的回答。如何得到正态频率分布曲线?非常感谢您的详细解释和回答!!
(hist(x2))                 # this is the command; rest is output
$breaks                                                                                                                 
[1]  5 10 15 20 25 30 35                                                                                                

$counts                                                                                                                 
[1] 12  7  7  2  0  1                                                                                                   

$density
[1] 0.082758621 0.048275862 0.048275862 0.013793103 0.000000000 0.006896552

$mids
[1]  7.5 12.5 17.5 22.5 27.5 32.5

$xname
[1] "x2"

$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
hh = hist(x2)
bb = hh$breaks

hh.breaks = as.character()
for(i in 2:length(bb)) {
    hh.breaks[i-1]=paste0(bb[i-1],'-',bb[i])
}
dd = data.frame(hh.breaks, hh$counts, hh$density, hh$mids)

dd

 hh.breaks hh.counts  hh.density hh.mids
1      5-10        12 0.082758621     7.5
2     10-15         7 0.048275862    12.5
3     15-20         7 0.048275862    17.5
4     20-25         2 0.013793103    22.5
5     25-30         0 0.000000000    27.5
6     30-35         1 0.006896552    32.5