Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

R 百分位数


百分位数

百分位数用于统计学中,它提供一个数值来描述给定百分比的值低于该数值。

如果我们看一下mtcars数据集中的wt(重量)变量的值

wt(重量)的观察

1.513 1.615 1.835 1.935 2.140 2.200 2.320 2.465
2.620 2.770 2.780 2.875 3.150 3.170 3.190 3.215
3.435 3.440 3.440 3.440 3.460 3.520 3.570 3.570
3.730 3.780 3.840 3.845 4.070 5.250 5.345 5.424

汽车重量的第75个百分位数是多少?答案是3.61或3610磅,这意味着75%的汽车重量为3610磅或更少。

示例

Data_Cars <- mtcars

#c()指定您想要的百分位数
quantile(Data_Cars$wt, c(0.75))

结果

75% 
3.61
自己试试 »

如果您在不指定c()参数的情况下运行quantile()函数,您将获得0、25、50、75和100的百分位数。

示例

Data_Cars <- mtcars

quantile(Data_Cars$wt)

结果

     0%     25%     50%     75%    100% 
1.51300 2.58125 3.32500 3.61000 5.42400 
自己试试 »

四分位数

四分位数是数据按升序排序后被分成四个部分。

  1. 第一四分位数的值截断了前25%的数据。
  2. 第二四分位数的值截断了前50%的数据。
  3. 第三四分位数的值截断了前75%的数据。
  4. 第四四分位数的值截断了100%的数据。

使用quantile()函数获取四分位数。


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.