A- လမ်းကြောင်းများတွင် စက်ဝိုင်းပုံဆွဲနည်း- ဥပမာများဖြင့်
R တွင် လမ်းကြောင်းတစ်ခုရှိ စက်ဝိုင်းတစ်ခုဆွဲရန် အောက်ပါနည်းလမ်းများကို အသုံးပြုနိုင်သည်။
နည်းလမ်း 1- Base R ကိုအသုံးပြု၍ စက်ဝိုင်းတစ်ခုဆွဲပါ။
library (plotrix)
#create scatterplot
plot(x, y)
#add circle at specific (x, y) coordinates with specific radius
draw.draw. circle (x=3, y=8, radius=.5)
နည်းလမ်း 2- ggplot2 ကိုအသုံးပြု၍ စက်ဝိုင်းတစ်ခုဆွဲပါ။
library (ggplot2) library (ggforce) #create scatter plot with circle at specific location with specific radius ggplot(data = df, aes(x, y)) + geom_point() + geom_circle(aes(x0=3, y0=8, r=1), inherit. aes = FALSE ) + coordinate_fixed()
အောက်ဖော်ပြပါ ဥပမာများသည် နည်းလမ်းတစ်ခုစီကို လက်တွေ့အသုံးချနည်းကို ပြသထားသည်။
ဥပမာ 1- Base R ကိုအသုံးပြု၍ စက်ဝိုင်းတစ်ခုဆွဲပါ။
အခြေခံ R ကွက်ကွက်တစ်ခုပေါ်တွင် စက်ဝိုင်းတစ်ခုဆွဲရန်၊ သင်ဦးစွာ plotrix ပက်ကေ့ဂျ်ကို ထည့်သွင်းပြီး တင်ရပါမည်။
install. packages (' plotrix ')
library (plotrix)
ထို့နောက်၊ အခြေခံ R point cloud သို့ စက်ဝိုင်းထည့်ရန် plotrix package မှ draw.circle() function ကို သုံးနိုင်သည်-
#create data frame
df <- data. frame (x=c(1, 2, 2, 3, 3, 4, 8),
y=c(2, 4, 5, 4, 7, 9, 10))
#create scatterplot
plot(df$x, df$y)
#add circle
draw.draw. circle (x=3, y=8, radius=.5)
တူညီသောလမ်းကြောင်းပေါ်တွင် စက်ဝိုင်းများစွာကို ဆွဲရန် draw.circle() လုပ်ဆောင်ချက်ကို အကြိမ်များစွာ အသုံးပြုနိုင်သည်။
#create data frame
df <- data. frame (x=c(1, 2, 2, 3, 3, 4, 8),
y=c(2, 4, 5, 4, 7, 9, 10))
#create scatterplot
plot(df$x, df$y)
#add multiple circles to plot
draw.draw. circle (x=3, y=8, radius=.5)
draw.draw. circle (x=4, y=5, radius=.5, border=' red ', col=' lightblue ', lwd=5, lty=' dashed ')
ကျွန်ုပ်တို့သတ်မှတ်ထားသော (x၊ y) သြဒိနိတ်များတွင် စက်ဝိုင်းများစွာကို ကွက်ကွက်ထဲသို့ ထည့်ထားကြောင်း သတိပြုပါ။
ဥပမာ 2- ggplot2 ကိုအသုံးပြု၍ စက်ဝိုင်းတစ်ခုဆွဲပါ။
ggplot2 ရှိ ကွက်ကွက်တစ်ခုပေါ်တွင် စက်ဝိုင်းတစ်ခုဆွဲရန်၊ သင်သည် ggplot2 နှင့် ggforce ပက်ကေ့ဂျ်များကို ဦးစွာထည့်သွင်းပြီး တင်ရပါမည်။
install. packages (' ggplot2 ')
install. packages (' ggforce ')
library (ggplot2)
library (ggforce)
ထို့နောက်၊ ggplot2 ရှိ scatterplot တွင် စက်ဝိုင်းတစ်ခုထည့်ရန် ggforce package မှ geom_circle() လုပ်ဆောင်ချက်ကို အသုံးပြုနိုင်သည်။
#create data frame
df <- data. frame (x=c(1, 2, 2, 3, 3, 4, 8),
y=c(2, 4, 5, 4, 7, 9, 10))
#create scatter plot with circle
ggplot(data = df, aes(x, y)) +
geom_point() +
geom_circle(aes(x0=3, y0=8, r=1), linetype=' dashed ', color=' red ',
fill=' lightblue ', lwd=1.5, inherit. aes = FALSE ) +
coordinate_fixed()
စက်ဝိုင်းကို ကျွန်ုပ်တို့သတ်မှတ်ထားသော တိကျသောသြဒီနိတ်များ (x၊ y) တွင် ထားရှိထားပါသည်။
မှတ်ချက် – coord_fixed() အငြင်းအခုံကို အသုံးမပြုပါက၊ စက်ဝိုင်းသည် ellipse အဖြစ် ပေါ်လာနိုင်သည်။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် R တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
ကိန်းရှင်များစွာဖြင့် R တွင် scatterplot တစ်ခုကို ဖန်တီးနည်း
R ဖြင့် ခွဲခြမ်းစိတ်ဖြာမှုတစ်ခုတွင် အမှတ်အသားပြုနည်း
R တွင်ကွက်ကွက်တစ်ခုသို့ regression equation ကိုမည်သို့ထည့်ရမည်နည်း။