|R| Experts
1.08K subscribers
375 photos
35 videos
58 files
204 links
@R_Experts
🔴آمار علم جان بخشیدن به داده‌هاست.
🔷ارتباط با ما
@iamrezaei
لینک یوتیوب و اینستاگرام و ویرگول:
https://zil.ink/expertstv
Download Telegram
The above plot is just a basic histogram. Let's add some parameters:

•br=20, #divide the data into 20 bars
•col="blue", #fill in blue color
•main="Histogram of Expression", #title of the histogram
•xlab="Expression", #x axis description
•ylab="Frequency", #y axis description
•freq=TRUE, #y axis is the frequency of each interval


Here is the command:

>hist(ex,br=14,col="blue",xlab="Expression",ylab="Frequency",
+freq=TRUE,main="Histogram of Expression")


To add a density line into the histogram, we need to change two parameters:

•freq=FALSE, #y axis is the density value of each interval
•ylab="Density", #y axis description as Density


Here is the command:

>hist(ex,br=14,col="blue",xlab="Expression",ylab="Density",freq=FALSE,
+main="Histogram of Expression")
>lines(density(ex),col="red")


We can write the plot into a file:

>png("histogram3.png",400,300)
>hist(ex,br=14,col="blue",xlab="Expression",ylab="Density",
+freq=FALSE,main="Histogram of Expression")
>lines(density(ex),col="red")
>graphics.off()


@R_Experts
#Boxplot
usually refers to box-and-whisker plot, which is a popular method to show data by drawing a box around the 1st and 3rd quartile, and the whiskers for the smallest and largest data values, the median is represented by a bold line in the box.

Following is a csv file example "boxplot.csv", we will draw a boxplot of "Expression" based on Subtype "A", "B" and "C".

Let first read in the data from the file:

> x <- read.csv("boxplot.csv",header=T,sep="\t")
> x <- t(x)
> a <- as.numeric(x[2,1:143])
> b <- as.numeric(x[2,144:218])
> c <- as.numeric(x[2,219:ncol(x)])


Box plot based on subtype A, B and C:

> boxplot(a,b,c,col=c("red","blue","green"),names=c("A","B","C"),
+ xlab="Subtype",ylab="Expression")


The above plot shows that the Expression values for Subtype A, B and C are similar, however the two sub-boxes around the median of Subtype C is wider than B and A, the data are not symmetrically distributed around the median.

if the 'notch' parameter is 'TRUE', a notch is drawn in each side of the boxes. If the notches of two plots do not overlap this is 'strong evidence' that the two medians differ.

> boxplot(a,b,c,col=c("red","blue","green"),names=c("A","B","C"), 
+ notch=TRUE, xlab="Subtype",ylab="Expression")


We can write the plot into a file:

> png("boxplot1.png",400,300)
> boxplot(a,b,c,col=c("red","blue","green"),names=c("A","B","C"),
+ xlab="Subtype",ylab="Expression")
> graphics.off()


@R_Experts
#abline


abline()

function adds a line to plot. It's expression is:

abline(a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL,
coef = NULL, untf = FALSE, ...)



a,b

:Intercept and slope
h

:for horizontal line
v

:for vertical line
...

First let's make a 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")
>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")


Let's add a red horizontal line at y=4 to the plot:

>abline(h=4,col="red")


Let's add a green vertical line at x=0 to the plot:

>abline(v=0,col="green")

Let's add a blue line with intercept 2 and slope 2 to the plot:

>abline(a=2,b=2,col="blue")


@R_Experts
#پاسخ_تمرین_8
> i<- 10:100
> sum(i^3+4*i^2)
[1] 26852735
>
> rm(list = ls())
>
>
> i <- 1:25
> sum((2^i)/i + 3^i/(i^2))
[1] 2129170437
>



پاسخ ارسالی خانم کاظمی:

> rm(list = ls())
> suma = function(a, b){
+ for(i in a:b){
+ s = i^3 + 4 * i ^ 2
+ }
+ return(s)
+ }
> suma(10, 100)
[1] 1040000
> #b
> sumb = function(a, b){
+ for(i in a:b){
+ s = ((2^i)/ i) + ((3^i)/(i^2))
+ }
+ return(s)
+ }
> sumb(1, 25)
[1] 1357003952
> sumb(1, 25)


ارسالی آقای مزرجی:
> rm(list = ls())
>
> i=0
> for (i in 10:100){
+ a=sum((i^3)+(4×(i^2)))
Error: unexpected input in:
"for (i in 10:100){
a=sum((i^3)+(4×"
> }
Error: unexpected '}' in "}"
> a
Error: object 'a' not found
>
>
> i=0
> for(i in 1:25){
+ b=sum(((2^i)/i)+((3^i)/(i^2)))
+ }
> b
[1] 1357003952
>


با تشکر از زحمات دوستان 🙏🙏🙏

@R_Experts
#R_cmdr

یکی از مشکلات این نرم افزار این است که برخی از کاربران با این زبان و نوشتن دستورات در این برنامه آشنایی ندارند بنابراین خود نرم افزار یک سری پکیچ های مخصوص را برای استفاده ی کاربران مبتدی قرار داده است یک از پر کاربرد ترین این پکیچ ها
 R commander (R cmdr )   

می باشد که یک رابط گرافیگی نرم افزار می باشد.
طریقه نصب این پکیچ مانند سایر پکیچ ها است که هم می توان فایل زیپ آن را دانلود و سپس نصب کرد و یا می توان
با استفاده دستورات تایپ در
"R Console"
ان را نصب کرد
دو روش را به صورت تصویری در شکل های زیر آورده ایم:
@R_Experts
#توضیحات_در_مورد_R_Cmdr


به طور کلی کلی رابط R commanderدارای فضای شکل زیر می باشد که به ترتیب

1- منوي Rcmdr
2منوی ابزار data
3گزینه های (R scriptاسکریپتها) و ( R markdownداده
های نشانه گذاری شده)
4پنجره خروجی
5پنجره اجرای دستور
6پنجره پیام
7پنجره ورود دستور
@R_Experts
#توضیحات_در_مورد_R_Cmdr
در قسمت منوی )1( Rcmdrشاهد منوی fileکه اغلب برای ذخیره سازی ، باز
کردن اسکریپت ، خروج و ....می باشیم.

منو انتخابی بعد منو editمی باشد که شامل ویرایش کردن دستورات ، کپی کردن،
برش ،و برچسب زدن و... میباشد.
@R_Experts
منوی dataکه شامل وارد کردن داده جدید خواندن داده ها از نرم افزار های دیگر
. و ... می باشدSpss,Exel,minitab مانند

منوی statisticکه شامل انجام کارهای آماری از جمله بدست آوردن خلاصه ای از
میانگین ، ماکزیمم ، مینیمم ، جدول احتمالات ، فاصله اطمینان و آزمون فرض،
خاصیت ها ، واریانس ، ناپارامتری ، آنالیز و مدل مناسب می باشد
منوی graphکه شامل انواع نمودار ها می باشد.

منوی modelکه شامل مدل های آماری است.

منوی distribustionکه شامل توابع پیوسته و گسسته است.

و در پایان منوی تنظیمات ( )toolsو منوی helpاست

@R_Experts