R တွင် percentile များကို လွယ်ကူစွာ တွက်ချက်နည်း (ဥပမာများဖြင့်)
ဒေတာအစုတစ်ခု၏ နံပါတ်တစ် ရာခိုင်နှုန်းသည် တန်ဖိုးအားလုံးကို အသေးဆုံးမှ အကြီးဆုံးသို့ စီခွဲသောအခါ ဒေတာတန်ဖိုးများ၏ ပထမ n ရာခိုင်နှုန်းကို ဖြတ်တောက်သည့်တန်ဖိုးဖြစ်သည်။
ဥပမာအားဖြင့်၊ ဒေတာအတွဲတစ်ခု၏ 90th ရာခိုင်နှုန်းသည် ဒေတာတန်ဖိုးများ၏ 90% အောက်ခြေကို ဒေတာတန်ဖိုးများ၏ 10% နှင့် ပိုင်းခြားထားသည့် တန်ဖိုးဖြစ်သည်။
အသုံးအများဆုံး ရာခိုင်နှုန်းတစ်ခုသည် ဒေတာအစုတစ်ခု၏ အလယ်အလတ်တန်ဖိုးကို ကိုယ်စားပြုသည့် 50th percentile ဖြစ်သည်- ၎င်းသည် ဒေတာတန်ဖိုးအားလုံး၏ 50% အောက်တွင် ကျရောက်သည့် တန်ဖိုးဖြစ်သည်။
Percentiles ကဲ့သို့သော မေးခွန်းများကို ဖြေရန်-
- ထိပ်တန်း 10% တွင် ကျောင်းသားတစ်ဦးသည် သီးခြားစာမေးပွဲတစ်ခုတွင် ရမှတ်မည်မျှလိုအပ်သနည်း။ ဤမေးခွန်းကိုဖြေဆိုရန်၊ ရမှတ်အားလုံး၏ 90th ရာခိုင်နှုန်းကို ရှာတွေ့မည်ဖြစ်ပြီး၊ အောက်ခြေ 90% ကို ထိပ်တန်း 10% နှင့် ပိုင်းခြားထားသော တန်ဖိုးဖြစ်သည်။
- ကျောင်းတစ်ခုခုရှိ ကျောင်းသားများ၏ ပျမ်းမျှ အမြင့်တစ်ဝက်ကို မည်သည့်အမြင့်များ လွှမ်းခြုံထားသနည်း။ ဤမေးခွန်းကိုဖြေဆိုရန်၊ အမြင့်၏ 75th ရာခိုင်နှုန်းနှင့် အမြင့်၏ 25th ရာခိုင်နှုန်းကို ရှာဖွေရမည်ဖြစ်ပြီး အမြင့်၏ 50% ၏ အထက်နှင့် အောက်အပိုင်းများကို ဆုံးဖြတ်ပေးသည့် တန်ဖိုးနှစ်ခုဖြစ်သည့် အမြင့်၏ 75th ရာခိုင်နှုန်းနှင့် အမြင့်၏ 25th ရာခိုင်နှုန်းကို ရှာဖွေမည်ဖြစ်သည်။
R တွင် ရာခိုင်နှုန်းများ တွက်နည်း
အောက်ပါ syntax ကိုအသုံးပြုသည့် quantile() လုပ်ဆောင်ချက်ကို အသုံးပြု၍ R တွင် ရာခိုင်နှုန်းများကို အလွယ်တကူ တွက်ချက်နိုင်သည်-
quantile (x၊ probs = seq(0၊ 1၊ 0.25))
- x- ကျွန်ုပ်တို့ရှာလိုသော ရာခိုင်နှုန်းများရှိသည့် ကိန်းဂဏာန်း ကိန်းဂယက်
- probs − ကျွန်ုပ်တို့ရှာဖွေလိုသော ရာခိုင်နှုန်းများကို ကိုယ်စားပြုသည့် [0,1] ရှိ ဖြစ်နိုင်ခြေရှိသော ကိန်းဂဏန်း vector တစ်ခု
vector တစ်ခု၏ ရာခိုင်နှုန်းများကို ရှာဖွေခြင်း။
အောက်ပါကုဒ်သည် R တွင် ပေးထားသော vector တစ်ခုအတွက် မတူညီသော ရာခိုင်နှုန်းများကို မည်သို့ရှာဖွေရမည်ကို သရုပ်ဖော်ထားသည်။
#create vector of 100 random values uniformly distributed between 0 and 500 data <- runif(100, 0, 500) #Find the quartiles (25th, 50th, and 75th percentiles) of the vector quantile (data, probs = c(.25, .5, .75)) # 25% 50% 75% #97.78961 225.07593 356.47943 #Find the deciles (10th, 20th, 30th, ..., 90th percentiles) of the vector quantile (data, probs = seq(.1, .9, by = .1)) # 10% 20% 30% 40% 50% 60% 70% 80% #45.92510 87.16659 129.49574 178.27989 225.07593 300.79690 337.84393 386.36108 #90% #423.28070 #Find the 37th, 53rd, and 87th percentiles quantile (data, probs = c(.37, .53, .87)) # 37% 53% 87% #159.9561 239.8420 418.4787
ဒေတာဘောင်ကော်လံတစ်ခု၏ ရာခိုင်နှုန်းများကို ရှာဖွေခြင်း။
တိကျသောဒေတာဘောင်ကော်လံတစ်ခု၏ ရာခိုင်နှုန်းများကို မည်သို့ရှာရပုံကို သရုပ်ဖော်ရန် ကျွန်ုပ်တို့သည် တပ်ဆင်ထားသောဒေတာအတွဲ iris ကို အသုံးပြုပါမည်-
#view first six rows of iris dataset
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
အောက်ဖော်ပြပါကုဒ်သည် Sepal.Length ကော်လံအတွက် 90th ရာခိုင်နှုန်းတန်ဖိုးကို မည်သို့ရှာဖွေရမည်ကို ပြသသည်-
quantile (iris$Sepal.Length, probs = 0.9)
#90%
#6.9
ဒေတာဘောင်ကော်လံအများအပြား၏ ရာခိုင်နှုန်းများကို ရှာဖွေခြင်း။
apply() လုပ်ဆောင်ချက်ကို အသုံးပြု၍ ကော်လံအများအပြား၏ ရာခိုင်နှုန်းများကို တစ်ပြိုင်နက် ရှာဖွေနိုင်သည်-
#define columns we want to find percentiles for small_iris<- iris[, c('Sepal.Length', 'Sepal.Width', 'Petal.Length', 'Petal.Width')] #use apply() function to find 90th percentile for every column apply (small_iris, 2, function(x) quantile(x, probs = .9)) #Sepal.Length Sepal.Width Petal.Length Petal.Width #6.90 3.61 5.80 2.20
အုပ်စုအလိုက် ရာခိုင်နှုန်းများကို ရှာဖွေခြင်း။
dplyr စာကြည့်တိုက်မှ group_by() လုပ်ဆောင်ချက်ကို အသုံးပြု၍ R တွင် အုပ်စုအလိုက် ရာခိုင်နှုန်းများကို ရှာဖွေနိုင်သည်။
အောက်ပါကုဒ်သည် တစ်ခုစီအတွက် Sepal.Length ၏ 90th ရာခိုင်နှုန်းကို မည်သို့ရှာဖွေရမည်ကို သရုပ်ပြသည်
မျက်ဝန်းဒေတာအတွဲတွင် အမျိုးအစားသုံးမျိုး
#load dplyr library library(dplyr) #find 90th percentile of Sepal.Length for each of the three species iris %>% group_by (Species) %>% summarize (percent90 = quantile(Sepal.Length, probs = .9)) # A tibble: 3 x 2 #Speciespercent90 # #1 setosa 5.41 #2 versicolor 6.7 #3 virginica 7.61
အောက်ပါကုဒ်သည် မျိုးစိတ်အလိုက် ကိန်းရှင်အားလုံးအတွက် 90th ရာခိုင်နှုန်းကို မည်သို့ရှာဖွေရမည်ကို ဖော်ပြသည်-
iris %>% group_by (Species) %>% summarize (percent90_SL = quantile(Sepal.Length, probs = .9), percent90_SW = quantile(Sepal.Width, probs = .9), percent90_PL = quantile(Petal.Length, probs = .9), percent90_PW = quantile(Petal.Width, probs = .9)) # A tibble: 3 x 5 # Species percent90_SL percent90_SW percent90_PL percent90_PW # #1 setosa 5.41 3.9 1.7 0.4 #2 versicolor 6.7 3.11 4.8 1.51 #3 virginica 7.61 3.31 6.31 2.4
ရာခိုင်နှုန်းများကိုကြည့်ရှုခြင်း။
R ရှိ ဒေတာအတွဲတစ်ခု၏ ရာခိုင်နှုန်းများကို မြင်သာစေရန် ပါ၀င်သည့်လုပ်ဆောင်ချက်မရှိသော်လည်း၊ ကျွန်ုပ်တို့သည် ရာခိုင်နှုန်းအတော်လေးလွယ်ကူစွာ မြင်သာစေရန် ကွက်ကွက်တစ်ခုကို ဖန်တီးနိုင်သည်။
အောက်ဖော်ပြပါ ကုဒ်သည် Sepal.Length ဒေတာတန်ဖိုးများအတွက် iris ဒေတာအတွဲအတွက် ရာခိုင်နှုန်းကွက်ကွက်ဖန်တီးနည်းကို သရုပ်ပြသည်-
n = length(iris$Sepal.Length) plot((1:n - 1)/(n - 1), sort(iris$Sepal.Length), type="l", main = "Visualizing Percentiles", xlab = "Percentile", ylab = "Value")
ထပ်လောင်းအရင်းအမြစ်များ
R တွင် apply(), lapply(), sapply() နှင့် tapply() တို့ဖြစ်သည်။
mutate() နှင့် case_when() ဖြင့် R တွင် variable အသစ်များကိုဖန်တီးပါ။