R 一些非常用函数
程序员文章站
2022-03-11 21:41:01
...
R一些非常用函数
1. identical
identical(x,y) ## 鉴别两个对象是否完全一致,等同于all(x==y)
2.surv_cutpoint
surv_cutpoint,生信分析中生存分析中使用的可以找到合适的划分点使得生存存在差异,
遗憾的是这个函数只能用于两组间的cutoff值,需配合surv_categorize(res.cut)食用
示例:# 0. Load some data
data(myeloma)
head(myeloma)
# 1. Determine the optimal cutpoint of variables
res.cut <- surv_cutpoint(myeloma, time = "time", event = "event",
variables = c("DEPDC1", "WHSC1", "CRIM1"))
summary(res.cut)
# 2. Plot cutpoint for DEPDC1
# palette = "npg" (nature publishing group), see ?ggpubr::ggpar
plot(res.cut, "DEPDC1", palette = "npg")
# 3. Categorize variables
res.cat <- surv_categorize(res.cut)
head(res.cat)
# 4. Fit survival curves and visualize
library("survival")
fit <- survfit(Surv(time, event) ~DEPDC1, data = res.cat)
ggsurvplot(fit, data = res.cat, risk.table = TRUE, conf.int = TRUE)
下一篇: Spring 整合 Mybatis