ပြင်ဆင်နည်း- do_one(nmeth) တွင် အမှားအယွင်း- နိုင်ငံခြားလုပ်ဆောင်ချက်ခေါ်ဆိုမှုတွင် na/nan/inf (arg 1)
R တွင် သင်ကြုံတွေ့နိုင်သော အမှားတစ်ခုမှာ-
Error in do_one(nmeth): NA/NaN/Inf in foreign function call (arg 1)
R တွင် k-means အစုအဝေးကို လုပ်ဆောင်ရန် ကြိုးပမ်းသောအခါတွင် ဤအမှားသည် သင်အသုံးပြုနေသည့် ဒေတာဘောင်တွင် တစ်ခု သို့မဟုတ် တစ်ခုထက်ပိုသော တန်ဖိုးများ ပျောက်ဆုံးနေပါသည်။
ဤသင်ခန်းစာတွင် ဤအမှားကို မည်သို့ပြင်ရမည်ကို တိတိကျကျ ရှင်းပြထားသည်။
အမှားကို ဘယ်လိုပြန်ထုတ်မလဲ။
ဒုတိယအတန်းတွင် ပျောက်နေသောတန်ဖိုးတစ်ခု R တွင် အောက်ပါဒေတာဘောင်တစ်ခုရှိသည်ဆိုပါစို့။
#create data frame df <- data. frame (var1=c(2, 4, 4, 6, 7, 8, 8, 9, 9, 12), var2=c(12, 14, 14, 8, 8, 15, 16, 9, 9, 11), var3=c(22, NA, 23, 24, 28, 23, 19, 16, 12, 15)) row. names (df) <- LETTERS[1:10] #view data frame df var1 var2 var3 At 2 12 22 B 4 14 NA C 4 14 23 D 6 8 24 E 7 8 28 F 8 15 23 G 8 16 19 H 9 9 16 I 9 9 12 D 12 11 15
ဤဒေတာဘောင်တွင် k-means အစုအဝေးကို လုပ်ဆောင်ရန် kmeans() လုပ်ဆောင်ချက်ကို အသုံးပြုရန် ကြိုးစားပါက၊ ကျွန်ုပ်တို့သည် အမှားအယွင်းတစ်ခု ရရှိလိမ့်မည်-
#attempt to perform k-means clustering with k = 3 clusters km <- kmeans(df, centers = 3 ) Error in do_one(nmeth): NA/NaN/Inf in foreign function call (arg 1)
အမှားကိုဘယ်လိုပြင်မလဲ။
ဤအမှားကို ပြင်ဆင်ရန် အလွယ်ကူဆုံးနည်းလမ်းမှာ ဒေတာဘောင်မှ ပျောက်ဆုံးနေသော တန်ဖိုးများပါရှိသော အတန်းများကို ဖယ်ရှားရန် na.omit() လုပ်ဆောင်ချက်ကို အသုံးပြုရန်ဖြစ်သည်။
#remove rows with NA values df <- na. omitted (df) #perform k-means clustering with k = 3 clusters km <- kmeans(df, centers = 3) #view results km K-means clustering with 3 clusters of sizes 4, 3, 2 Cluster means: var1 var2 var3 1 5.5 14.250000 21.75000 2 10.0 9.666667 14.33333 3 6.5 8.000000 26.00000 Vector clustering: ACDEFGHIJ 1 1 3 3 1 1 2 2 2 Within cluster sum of squares by cluster: [1] 46.50000 17.33333 8.50000 (between_SS / total_SS = 79.5%) Available components: [1] "cluster" "centers" "totss" "withinss" "tot.withinss" [6] "betweenss" "size" "iter" "ifault"
ဒေတာဘောင်မှ လွဲမှားနေသော တန်ဖိုးများပါသည့် အတန်းများကို ဖယ်ရှားလိုက်သည်နှင့် k-ဆိုလိုသည်မှာ အစုလိုက်အပြုံလိုက် အယ်လဂိုရီသမ်သည် အောင်မြင်စွာ လုပ်ဆောင်ကြောင်း သတိပြုပါ။
အပိုဆု- k-အဓိပ္ပာယ်ကို R တွင် အစုအဝေးပြုလုပ်ရန်အတွက် ပြီးပြည့်စုံသော အဆင့်ဆင့်လမ်းညွှန်ချက်
ထပ်လောင်းအရင်းအမြစ်များ
အကျပ်ကိုင်မှုဖြင့် မိတ်ဆက်ပေးခဲ့သော R- NAs တွင် မည်ကဲ့သို့ ပြင်ဆင်ရမည်နည်း။
R- အညွှန်းကို ဘောင်အတွင်းမှ ပြုပြင်နည်း
R ဖြင့် ပြုပြင်နည်း- ပိုရှည်သော အရာဝတ္ထုတစ်ခု၏ အလျားသည် ပိုတိုသော အရာဝတ္ထုတစ်ခု၏ အလျားများစွာမဟုတ်ပေ။