ggforify 这个包很值得我写一个文档来介绍他。因为很方便,他是ggplot2包的一个增强版。开始介绍。
library(ggfortify)
library(survival)
autoplot(aareg(Surv(time, status) ~ age + sex + ph.ecog, data = lung, nmin = 1))
autoplot(stats::acf(AirPassengers, plot = FALSE)) # 自相关图
autoplot(stats::pacf(AirPassengers, plot = FALSE)) # 偏自相关图
autoplot(stats::ccf(AirPassengers, AirPassengers, plot = FALSE)) # ccf 图
autoplot(stats::density(stats::rnorm(1:50)))
autoplot(stats::density(stats::rnorm(1:50)), fill = 'blue')
d.arima <- forecast::auto.arima(AirPassengers)
autoplot(forecast::forecast(d.arima, h = 10))
autoplot(forecast::forecast(d.arima, level = c(85), h = 10))
autoplot(forecast::forecast(d.arima, h = 5), conf.int = FALSE, is.date = FALSE)
autoplot(forecast::forecast(stats::HoltWinters(UKgas), h = 10))
autoplot(forecast::forecast(forecast::ets(UKgas), h = 5))
autoplot(stats::kmeans(iris[-5], 3), data = iris)
autoplot(cluster::clara(iris[-5], 3), label = TRUE)
autoplot(cluster::fanny(iris[-5], 3))
autoplot(cluster::fanny(iris[-5], 3), frame = TRUE)
autoplot(cluster::pam(iris[-5], 3), data = iris, colour = 'Species')
autoplot(cluster::pam(iris[-5], 3), data = iris, frame = TRUE, frame.type = 't')
autoplot(matrix(rnorm(20), nc = 5))
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
autoplot(matrix(rnorm(20), nc = 5), fill = 'red')
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
autoplot(matrix(rnorm(20), nc = 2), geom = 'point')
autoplot(stats::prcomp(iris[-5]))
autoplot(stats::prcomp(iris[-5]), data = iris)
autoplot(stats::prcomp(iris[-5]), data = iris, colour = 'Species')
autoplot(stats::prcomp(iris[-5]), data = iris, frame = TRUE,
frame.colour = 'Species')
autoplot(stats::prcomp(iris[-5]), data = iris, frame = TRUE,
frame.type = 't', frame.colour = 'Species')
library(survival)
library(ggfortify)
autoplot(survfit(Surv(time, status) ~ sex, data = lung))
autoplot(survfit(Surv(time, status) ~ sex, data = lung), facets = TRUE)
autoplot 是一大类函数,你可以将多种对象传递进去,然后生成相应图形