#تمرین_شماره_11
این تمرین کاملا اختیاری است و دوستانی که میخواهند با R Cmdr آشنا شودند به آن پاسخ دهند.
با استفاده از پکیچ R cmdr یک نمونه تصادفی 100 تایی از یک توزیع #دوجمله_ای_منفی و یک نمونه 80 تایی از توزیع
#وایبل تولید کنید و نام نمونه اول R_Experts و نام نمونه ی دوم را با دلخواه خودتان انتخاب کنید.
#تذکر : لازم به ذکر میدانم یادآوری کنم ،دوستان اینگونه تصور نکند که ما 2+2 را حساب کرده ایم و حالا
جرم ماه رو میخواهیم . R cmdr شبیه تمامی نرم افزار های منویی اسان بوده و نیاز به
برنامه نویسی ندارد فقط کمی دقت می خواهد
بی صبرانه منتظر جواب عزیزان هستیم.
پاسخ خود را به یک از ای دی های زیر ارسال نمایید
@Analyst20
@javad_vhd
@hamedrezaei2
با تشکر از تمامی عزیزانی که با ارسال جواب ما را تشویق می نمایند.
@R_Experts
این تمرین کاملا اختیاری است و دوستانی که میخواهند با R Cmdr آشنا شودند به آن پاسخ دهند.
با استفاده از پکیچ R cmdr یک نمونه تصادفی 100 تایی از یک توزیع #دوجمله_ای_منفی و یک نمونه 80 تایی از توزیع
#وایبل تولید کنید و نام نمونه اول R_Experts و نام نمونه ی دوم را با دلخواه خودتان انتخاب کنید.
#تذکر : لازم به ذکر میدانم یادآوری کنم ،دوستان اینگونه تصور نکند که ما 2+2 را حساب کرده ایم و حالا
جرم ماه رو میخواهیم . R cmdr شبیه تمامی نرم افزار های منویی اسان بوده و نیاز به
برنامه نویسی ندارد فقط کمی دقت می خواهد
بی صبرانه منتظر جواب عزیزان هستیم.
پاسخ خود را به یک از ای دی های زیر ارسال نمایید
@Analyst20
@javad_vhd
@hamedrezaei2
با تشکر از تمامی عزیزانی که با ارسال جواب ما را تشویق می نمایند.
@R_Experts
#جواب_تمرین_شماره_11
تنها عزیزی که به این تمرین جواب داده است کسی نیست جز آقای
بدین وسیله
@R_Experts
نهایت سپاس از ایشان را نموده و موفقیت رو افزونشان را از درگاه خداوند منان خواستار است.
با تشکر فراوان از تمامی اعضای کانال
https://telegram.me/R_Experts
تنها عزیزی که به این تمرین جواب داده است کسی نیست جز آقای
Naser Mezerji
بدین وسیله
@R_Experts
نهایت سپاس از ایشان را نموده و موفقیت رو افزونشان را از درگاه خداوند منان خواستار است.
با تشکر فراوان از تمامی اعضای کانال
https://telegram.me/R_Experts
Telegram
|R| Experts
@R_Experts
🔴آمار علم جان بخشیدن به دادههاست.
🔷ارتباط با ما
@iamrezaei
لینک یوتیوب و اینستاگرام و ویرگول:
https://zil.ink/expertstv
🔴آمار علم جان بخشیدن به دادههاست.
🔷ارتباط با ما
@iamrezaei
لینک یوتیوب و اینستاگرام و ویرگول:
https://zil.ink/expertstv
#Points
function adds a group of points to plot. It's usage is:
x,y:Vector of coordinates
First let's make a scatter plot:
Add some points to the plot:
Notice that there is a point almost out of the left border. If the added points are out of the plot border, they were not be added to the plot. In the example above, the smallest value of x is -2.1, and largest is 5.6, the y value range is -3 < y < 13, so the added points should be inside that range.
The cex= controls the size of the points, pch= controls the point shape, and col= controls the point color. Here is a list of all pch symbols, and here is a complete chart of R color names. Let add some points of filled diamond shape, large size, and red color:
@R_Experts
points(...)
function adds a group of points to plot. It's usage is:
points(x, y, ...)
x,y:Vector of coordinates
First let's make a scatter plot:
>x <- c(1.2,3.4,1.3,-2.1,5.6,2.3,3.2,2.4,2.1,1.8,1.7,2.2)
>y <- c(2.4,5.7,2.0,-3,13,5,6.2,4.8,4.2,3.5,3.7,5.2)
>plot(x,y,cex=.8,pch=1,xlab="x",ylab="y",col="black")
Add some points to the plot:
>x2 <- c(4.1,1.1,-2.3,-0.2,-1.2,2.3)
>y2 <- c(2.3,4.2,1.2,2.1,-2,4.3)
>points(x2,y2,cex=.8,pch=3,col="blue")
Notice that there is a point almost out of the left border. If the added points are out of the plot border, they were not be added to the plot. In the example above, the smallest value of x is -2.1, and largest is 5.6, the y value range is -3 < y < 13, so the added points should be inside that range.
The cex= controls the size of the points, pch= controls the point shape, and col= controls the point color. Here is a list of all pch symbols, and here is a complete chart of R color names. Let add some points of filled diamond shape, large size, and red color:
>x3 <- c(0,4)
>y3 <- c(10,-0.5)
>points(x3,y3,cex=4,pch=18,col="red")
@R_Experts
#Scatter_plot
Following is a csv file example, we will draw a Scatter Plot of the "Expression" and "Quality" values,
Let first read in the data from the file:
Draw a Scatter Plot:
If we want to draw different subtype in different color and symbol, we need more work like follows:
#regression expression ~ quality of BFollowing code can add a legend on the right:
R package "scatterplot3d" can be used to draw 3D scatter plots, to install this package:
To draw a 3D scatter plot based on the "Expression", "Quality" and "Height" values:
We can add more parameters like:
@R_Experts
Following is a csv file example, we will draw a Scatter Plot of the "Expression" and "Quality" values,
Let first read in the data from the file:
> x <- read.csv("scatterplot.csv",header=T,sep="\t")
> x <- t(x)
> ex <- as.numeric(x[2,1:ncol(x)])
> qu <- as.numeric(x[3,1:ncol(x)])
Draw a Scatter Plot:
> plot(ex,qu)
If we want to draw different subtype in different color and symbol, we need more work like follows:
> plot(ex,qu,col="white",xlab="Expression", ylab="Quality")
> points(ex[1:143],qu[1:143],col="red",pch=3,cex=.6) #Subtype A
> points(ex[144:218],qu[144:218],col="blue",pch=19,cex=.6) #Subtype B
> points(ex[219:ncol(x)],qu[219:ncol(x)],col="black",,pch=1,cex=.6) #Subtype C
> abline(lm(ex[144:218] ~ qu[144:218]),col="blue")
#regression expression ~ quality of BFollowing code can add a legend on the right:
> layout(matrix(c(1,2), nrow = 1), widths = c(0.7, 0.3))
> par(mar = c(5, 4, 4, 2) + 0.1)
> plot(ex,qu,col="white",xlab="Expression", ylab="Quality")
> points(ex[219:ncol(x)],qu[219:ncol(x)],col="black",,pch=1,cex=.6)
> points(ex[144:218],qu[144:218],col="blue",pch=19,cex=.6)
> points(ex[1:143],qu[1:143],col="red",cex=.6,pch=3)
> abline(lm(ex[144:218] ~ qu[144:218]),col="blue")
> par(mar = c(5, 0, 4, 1) + 0.1)
> plot(ex,qu,axes=FALSE,ann=FALSE, col="white")
> legend(x=-2.5,y=1.2,c("A (n=146)","B (n=77)","C (n=85)"),cex=.8, pch=c(1,19,3),col=c("black","blue", "red"))
R package "scatterplot3d" can be used to draw 3D scatter plots, to install this package:
> install.packages("scatterplot3d")
To draw a 3D scatter plot based on the "Expression", "Quality" and "Height" values:
> library(scatterplot3d)
> hi <- as.numeric(x[4,1:ncol(x)])
> scatterplot3d(ex,qu,hi,pch=20,highlight.3d=T)
We can add more parameters like:
scatterplot3d(ex,qu,hi,pch=20,highlight.3d=T,type="h")
@R_Experts
#Lattice
#Graphs
The lattice package, written by Deepayan Sarkar, attempts to improve on base R graphics by providing better defaults and the ability to easily display multivariate relationships.
In particular, the package supports the creation of trellis graphs - graphs that display a variable or the relationship between variables, conditioned on one or more other variables.
The typical format is
where graph_type is selected from the listed below.
formula specifies the variable(s) to display and any conditioning variables .
For example ~x|A means display numeric variable x for each level of factor A. y~x | A*B means display the relationship between numeric variables y and x separately for every combination of factor A and B levels. ~x means display numeric variable x alone.
@R_Experts
#Graphs
The lattice package, written by Deepayan Sarkar, attempts to improve on base R graphics by providing better defaults and the ability to easily display multivariate relationships.
In particular, the package supports the creation of trellis graphs - graphs that display a variable or the relationship between variables, conditioned on one or more other variables.
The typical format is
graph_type(formula, data=)
where graph_type is selected from the listed below.
formula specifies the variable(s) to display and any conditioning variables .
For example ~x|A means display numeric variable x for each level of factor A. y~x | A*B means display the relationship between numeric variables y and x separately for every combination of factor A and B levels. ~x means display numeric variable x alone.
@R_Experts
#Example _1
@R_Experts
install.packages("lattice")
library(lattice)
attach(mtcars)
#create factors with value labels
gear.f<-factor(gear,levels=c(3,4,5),
labels=c("3gears","4gears","5gears"))
cyl.f <-factor(cyl,levels=c(4,6,8),
labels=c("4cyl","6cyl","8cyl"))
# kernel density plot
densityplot(~mpg,
main="Density Plot",
xlab="Miles per Gallon")
@R_Experts