^_^简约而不简单!欢迎来到梅卫平の阅览室!您是第 位访客^_^

🌱 VIP绿色通道

(一)常用检索: 1. JCR-IF查询路径一, 路径二, 路径三      2. CiteScore-IF查询     3. SCI期刊检索     4. 中科院分区查询路径一, 路径二     5. SSCI检索     6. ESCI检索     7. EI检索 (备用)     8. ISTP检索
(二)备用网址: 1. 梅斯SCI期刊智能查询     2. 论文被SCI收录情况查询方法     3. CSCD期刊检索     4. 中国知网检索     5. PubChem     6. ChemSpider     7. 科研者之家     8. 爱科研
(三)google/sci-hub镜像: 1. 谷歌学术镜像一, 镜像二     2. Sci-Hub有效域名一, 域名二     3. scihub_button (GitHub Link)     4. LibGen英文Book下载
(四)ESI检索&Nature Index查询: 1. ESI查询      2. Nature Index查询      3. Nature Index Journal列表
(五)基金查询入口: 1. 国自然官方查询     2. 国自然梅斯查询     3. 国自然科学网查询

ggtrendline: an R package for adding trendline and confidence interval to ggplot

Links of ‘ggtrendline’ package are as follows: https://cran.r-project.org/package=ggtrendline and https://github.com/PhDMeiwp/ggtrendline


1. Installing “ggtrendline” package in R

1.1 Get the released version from CRAN:

install.packages("ggtrendline")

1.2 Get the development version from Github:

install.packages("devtools")
devtools::install_github("PhDMeiwp/ggtrendline@master", force = TRUE)
library(ggtrendline)

2. Using “ggtrendline” package

library(ggplot2)
library(ggtrendline)
x <- c(1, 3, 6, 9,  13,   17)
y <- c(5, 8, 11, 13, 13.2, 13.5)

2.1 default (“line2P”)

ggtrendline(x, y, model = "line2P")  

2.2 add geom_point()

ggtrendline(x, y, model = "line3P") + 
       geom_point(aes(x, y)) + theme_bw()

2.3 CI lines only, without CI filling

ggtrendline(x, y, model = "log2P", CI.fill = NA) + 
       geom_point(aes(x, y))+ theme_classic() 

2.4 set the regression line and geom_point()

ggtrendline(x, y, model = "exp2P", linecolor = "blue", linetype = 1, linewidth = 1) + 
        geom_point(aes(x, y), color = "blue", shape = 1, size = 3)  

2.5 set confidence interval

ggtrendline(x, y, model = "exp3P", CI.level = 0.99, 
           CI.fill = "red", CI.alpha = 0.1, CI.color = NA, CI.lty = 2, CI.lwd = 1.5) + 
        geom_point(aes(x, y)) 

2.6 one trendline with different points belonged to multiple groups.

library(ggplot2)
library(ggtrendline)
data("iris")
x <- iris$Petal.Width
y <- iris$Petal.Length
group <- iris$Species
ggtrendline(x,y,"exp3P") + geom_point(aes(x,y,color=group))

3. Details

3.1 Description

The ‘ggtrendline’ package is developed for adding trendline and confidence interval of linear or nonlinear regression model, and showing equation, R square, and P value to ‘ggplot’ as simple as possible.

For a general overview of the methods used in this package, see Ritz and Streibig (2008) doi:10.1007/978-0-387-09616-2 and Greenwell and Schubert Kabban (2014) doi:10.32614/RJ-2014-009.

3.2 ggtrendline function

The built-in ‘ggtrendline()’ function includes the following models:
“line2P”, formula as: y = a*x + b;
“line3P”, y = a*x2 + b*x + c;
“log2P” , y = a*ln(x) + b;
“exp2P”, y = a*eb*x;
“exp3P”, y = a*eb*x + c;
“power2P”, y = a*xb;
“power3P”, y = a*xb + c.

3.3 stat_eq and stat_rrp functions

The built-in ‘stat_eq()’ and ‘stat_rrp()’ functions can be used separately, i.e., not together with ‘ggtrendline()’ function.

To see more details, you can run the following R code if you have the “ggtrendline” package installed:

library(ggtrendline)
?ggtrendline
?stat_eq
?stat_rrp

4. Contact


5. Acknowledgements

We would like to express our special thanks to Uwe Ligges, Gregor Seyer, and CRAN team for their valuable comments to the ‘ggtrendline’ package.



<已有 次阅读>

由于本文作者水平有限,文中如有错误之处,欢迎大家批评指正!本文仅代表作者个人观点,不代表任何其它立场,欢迎交流合作!转载与分享请注明:本文源于 http://meiweiping.cn

^_^ 本文字数统计:546 字