R နံပါတ်များ


နံပါတ်များ

R တွင် နံပါတ်သုံးမျိုးရှိသည်။

  • numeric
  • integer
  • complex

၎င်းတို့အား သင်တန်ဖိုးတစ်ခုသတ်မှတ်သောအခါတွင် နံပါတ်အမျိုးအစားများ၏ ကိန်းရှင်များကို ဖန်တီးသည်-

ဥပမာ

x <- 10.5   # numeric
y <- 10L    # integer
z <- 1i     # complex

ဂဏာန်း

numericဒေတာအမျိုးအစားသည် R တွင် အသုံးအများဆုံးအမျိုးအစားဖြစ်ပြီး၊ 10.5၊ 55၊ 787 ကဲ့သို့သော ဒဿမတစ်ခုပါရှိသော သို့မဟုတ် မပါသည့် ဂဏန်းများပါရှိသည်

ဥပမာ

x <- 10.5
y <- 55

# Print values of x and y
x
y

# Print the class name of x and y
class(x)
class(y)

ကိန်းပြည့်

ကိန်းပြည့်များသည် ဒဿမများမပါဘဲ ကိန်းဂဏာန်းအချက်အလက်များဖြစ်သည်။ ဒဿမများပါဝင်သင့်သော ကိန်းရှင်တစ်ခုကို သင်ဘယ်တော့မှ ဖန်တီးမည်မဟုတ်ကြောင်း သင်သေချာသောအခါ ၎င်းကိုအသုံးပြုသည်။ ကိန်းရှင် တစ်ခုဖန်တီးရန် ၊ ကိန်းပြည့်တန်ဖိုးပြီးနောက် integer စာလုံးကို သင်အသုံးပြုရပါမည် -L

ဥပမာ

x <- 1000L
y <- 55L

# Print values of x and y
x
y

# Print the class name of x and y
class(x)
class(y)

ရှုပ်ထွေးသည်။

ကိန်းဂဏန်း တစ်ခုကို စိတ်ကူးယဉ်အပိုင်းအဖြစ် complex" " ဖြင့် ရေးထားသည် -i

ဥပမာ

x <- 3+5i
y <- 5i

# Print values of x and y
x
y

# Print the class name of x and y
class(x)
class(y)

ပြောင်းလဲခြင်းဟု ရိုက်ထည့်ပါ။

အောက်ပါလုပ်ဆောင်ချက်များဖြင့် သင်သည် အမျိုးအစားတစ်ခုမှ အခြားတစ်မျိုးသို့ ပြောင်းလဲနိုင်သည်။

  • as.numeric()
  • as.integer()
  • as.complex()

ဥပမာ

x <- 1L # integer
y <- 2 # numeric

# convert from integer to numeric:
a <- as.numeric(x)

# convert from numeric to integer:
b <- as.integer(y)

# print values of x and y
x
y

# print the class name of a and b
class(a)
class(b)