www.crosshyou.info

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

OECD Threatened species data analysis 4 - making bar plot with error bars in R

This blog is following of  

www.crosshyou.info

 In this blofg, I will make barplot with error bars.

1. check n(number of overbations) of each SUBJECT

f:id:cross_hyou:20210522191516p:plain

We see BIRD has 36, MAMAL has 34 and PLANT has 35 observations.

2. calculate average pf each SUBJECT

f:id:cross_hyou:20210522191642p:plain

We see BIRD has the highest average. Plant has the lowest average.

3. caclulate variance of each SUBJECT

f:id:cross_hyou:20210522191820p:plain

We see PLANT has the largest variance and MAMMAL has the smallest variance.

4. calculate S.E., standard error. Formula is sqrt(variance/n)

f:id:cross_hyou:20210522194132p:plain

We see PLANT has the largest S.E. and MAMMAL has the smallest S.E.

5. calculate C.I., confidence interval. Formula is t(alpha, d.f.)*S.E. We calculate 95% level C.I.

f:id:cross_hyou:20210522194612p:plain

6. calculate lower level of C.I. Formula is average - C.I. 

f:id:cross_hyou:20210522194750p:plain

7. calculate upper level of C.I.. Formula is average + C.I.

f:id:cross_hyou:20210522194917p:plain

All right, we get all values to make a bar plot with error bar.
We will use barplot() and arrows().

f:id:cross_hyou:20210522195229p:plain

f:id:cross_hyou:20210522195244p:plain

NIce!. Let's make a table for above data.

f:id:cross_hyou:20210522195401p:plain

That't is. Thank you for reading.

Next blog is

 

www.crosshyou.info

 


To read the first blog,

 

www.crosshyou.info