R တွင်သတိပေးချက်များကို မည်ကဲ့သို့ ဖိနှိပ်နည်း (ဥပမာများဖြင့်)
R တွင် သတိပေးချက်များကို ဖိနှိပ်ရန် အောက်ပါနည်းလမ်းများကို သင်အသုံးပြုနိုင်ပါသည်။
နည်းလမ်း 1- သတ်မှတ်ထားသောလိုင်းပေါ်ရှိ သတိပေးချက်များကို ဖယ်ရှားပါ။
suppressWarnings(one line of code)
နည်းလမ်း 2- ကမ္ဘာအနှံ့သတိပေးချက်များကို ဖယ်ရှားပါ။
suppressWarnings({ several lines of code just a bunch of code lots and lots of code })
အောက်ဖော်ပြပါနမူနာများသည် သတိပေးစာနှစ်စောင်ကိုထုတ်ပေးသည့် အောက်ပါကုဒ်ဖြင့် လက်တွေ့တွင် နည်းလမ်းတစ်ခုစီကို အသုံးပြုနည်းကို ပြသသည်-
#define character vector x <- c('1', '2', '3', NA, '4', 'Hey') #convert to numeric vector x_numeric <- as. numeric (x) #display digital vector print (x_numeric) Warning message: NAs introduced by coercion [1] 1 2 3 NA 4 NA #define two vectors a <- c(1, 2, 3, 4, 5) b <- c(6, 7, 8, 9) #add the two vectors a+b [1] 7 9 11 13 11 Warning message: In a + b: longer object length is not a multiple of shorter object length
နည်းလမ်း 1- သတ်မှတ်ထားသောလိုင်းပေါ်ရှိ သတိပေးချက်များကို ဖယ်ရှားပါ။
ကျွန်ုပ်တို့သည် ကုဒ်မှ ပထမဆုံးသတိပေးချက်ကိုသာ ဖိနှိပ်ရန် as.numeric( ) လုပ်ဆောင်ချက်ကို ဝိုင်းရံထားနိုင်သည်-
#define character vector x <- c('1', '2', '3', NA, '4', 'Hey') #convert to numeric vector suppressWarnings(x_numeric <- as.numeric (x)) #display digital vector print (x_numeric) [1] 1 2 3 NA 4 NA #define two vectors a <- c(1, 2, 3, 4, 5) b <- c(6, 7, 8, 9) #add the two vectors a+b [1] 7 9 11 13 11 Warning message: In a + b: longer object length is not a multiple of shorter object length
ပထမသတိပေးစာသည် မပေါ်တော့သော်လည်း ဒုတိယသတိပေးစာသည် ပေါ်လာဆဲဖြစ်ကြောင်း သတိပြုပါ။
နည်းလမ်း 2- ကမ္ဘာအနှံ့သတိပေးချက်များကို ဖယ်ရှားပါ။
တစ်ကမ္ဘာလုံးရှိ သတိပေးချက်အားလုံးကို ဖိနှိပ်ရန် ကုဒ်အပိုင်းတစ်ခုလုံးတွင် ဖိနှိပ်ထားသော သတိပေးချက်({}) လုပ်ဆောင်ချက်ကို ကျွန်ုပ်တို့ ခြုံထားနိုင်သည်-
suppressWarnings({ #define character vector x <- c('1', '2', '3', NA, '4', 'Hey') #convert to numeric vector suppressWarnings(x_numeric <- as.numeric (x)) #display digital vector print (x_numeric) [1] 1 2 3 NA 4 NA #define two vectors a <- c(1, 2, 3, 4, 5) b <- c(6, 7, 8, 9) #add the two vectors a+b [1] 7 9 11 13 11 })
ကျွန်ုပ်တို့သည် ကုဒ်အပိုင်းတစ်ခုလုံးတွင် ဖိနှိပ်သတိပေးချက်({}) လုပ်ဆောင်ချက်ကို ထည့်သွင်းထားသောကြောင့် ယခုတစ်ကြိမ်တွင် မည်သည့်သတိပေးချက်မျှ မရရှိကြောင်း သတိပြုပါ။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် R တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
သတိပေးချက် R ကိုရှောင်ရှားနည်း- getOption(“max.print”) သို့ရောက်ရှိ
R သတိပေးချက်ကို ကိုင်တွယ်ပုံ- glm.fit: အယ်လဂိုရီသမ် အသွင်မဆောင်ပါ။
ပြင်ဆင်နည်း- runtimewarning- double_scalars တွင် မမှန်ကန်သောတန်ဖိုးကို ကြုံတွေ့ခဲ့ရသည်။