diff --git a/DESCRIPTION b/DESCRIPTION index 1c599cf..f09957a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: ggfortify Type: Package Title: Data Visualization Tools for Statistical Analysis Results -Version: 0.0.4.9100 -Date: 2015-10-03 +Version: 0.1.0 +Date: 2015-11-30 Author: Masaaki Horikoshi and Yuan Tang Maintainer: Masaaki Horikoshi diff --git a/NEWS.rst b/NEWS.rst index 17f4d8e..3e81826 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,8 +1,8 @@ NEWS ===================== -ggfortify dev version ---------------------- +ggfortify v0.1.0 +---------------- - Compatible with ggplot2 v1.1.0 - Support glmnet diff --git a/R/fortify_stats.R b/R/fortify_stats.R index 290051f..70121a1 100644 --- a/R/fortify_stats.R +++ b/R/fortify_stats.R @@ -186,8 +186,10 @@ fortify.factanal <- function(model, data = NULL, ...) { #' @inheritParams fortify_base #' @return data.frame #' @examples +#' \dontrun{ #' model <- lfda::lfda(iris[, -5], iris[, 5], 3, metric = "plain") #' fortify(model) +#' } #' @export fortify.lfda <- function(model, data = NULL, ...) { diff --git a/R/geom.R b/R/geom.R index 60c7bba..a15ccd4 100644 --- a/R/geom.R +++ b/R/geom.R @@ -8,7 +8,7 @@ #' @param ... other arguments passed to methods geom_confint <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, ...) { - if (packageVersion("ggplot2") <= '1.0.1') { + if (utils::packageVersion("ggplot2") <= '1.0.1') { GeomConfint$new(mapping = mapping, data = data, stat = stat, position = position, na.rm = na.rm, ...) } else { @@ -21,7 +21,7 @@ geom_confint <- function (mapping = NULL, data = NULL, stat = "identity", } } -if (packageVersion("ggplot2") <= '1.0.1') { +if (utils::packageVersion("ggplot2") <= '1.0.1') { # mostly derived from ggplot2 # Licensed under GPL-2 # Link - https://github.com/hadley/ggplot2/blob/master/DESCRIPTION diff --git a/R/plotlib.R b/R/plotlib.R index 181a97f..3e2eb36 100644 --- a/R/plotlib.R +++ b/R/plotlib.R @@ -386,7 +386,7 @@ post_autoplot <- function(p, xlim = c(NA, NA), ylim = c(NA, NA), log = "", #' @return logical support_autoplot <- function(obj) { maybe_autoplot <- paste0('autoplot.', class(obj)) - return(any(sapply(maybe_autoplot, function(x) x %in% methods('autoplot')))) + return(any(sapply(maybe_autoplot, function(x) x %in% utils::methods('autoplot')))) } diff --git a/README.rst b/README.rst index 2cad5e1..dc753b4 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ ggfortify Define ``fortify`` and ``autoplot`` functions to allow ``ggplot2`` to handle some popular R packages. -**NOTE** For functions which returns ``list``, ``ggfortify`` tries to infer a background class using its attributes. Such functions are marked as "(inference)". +**NOTE** For functions which returns ``list``, ``ggfortify`` tries to infer a background class using its attribute names. Such functions are marked as "(inference)". This covers following classes: @@ -44,7 +44,7 @@ This covers following classes: - ``stats::acf`` - ``stats::ar`` - ``stats::Arima`` -- ``stats::cmdscale`` (inference, see the `doc `_) +- ``stats::cmdscale`` (inference) - ``stats::decomposed.ts`` - ``stats::density`` - ``stats::factanal`` diff --git a/man/fortify.lfda.Rd b/man/fortify.lfda.Rd index 5247b16..2a1c29f 100644 --- a/man/fortify.lfda.Rd +++ b/man/fortify.lfda.Rd @@ -20,7 +20,9 @@ data.frame Convert \code{lfda::lfda} or \code{lfda::klfda} or \code{lfda::self} to \code{data.frame} } \examples{ +\dontrun{ model <- lfda::lfda(iris[, -5], iris[, 5], 3, metric = "plain") fortify(model) } +} diff --git a/tests/testthat/test-stats.R b/tests/testthat/test-stats.R index aded320..8d3417b 100644 --- a/tests/testthat/test-stats.R +++ b/tests/testthat/test-stats.R @@ -118,25 +118,7 @@ test_that('fortify.princomp works for iris', { pcs <- c('Comp.1', 'Comp.2', 'Comp.3', 'Comp.4') expected_names <- c(names(df), pcs) - fortified <- ggplot2::fortify(stats::princomp(df, center = TRUE, scale = TRUE)) - expect_equal(is.data.frame(fortified), TRUE) - expect_equal(names(fortified), expected_names) - expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), df) - expect_equal(rownames(fortified), rownames(df)) - - fortified <- ggplot2::fortify(stats::princomp(df, center = FALSE, scale = TRUE)) - expect_equal(is.data.frame(fortified), TRUE) - expect_equal(names(fortified), expected_names) - expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), df) - expect_equal(rownames(fortified), rownames(df)) - - fortified <- ggplot2::fortify(stats::princomp(df, center = TRUE, scale = FALSE)) - expect_equal(is.data.frame(fortified), TRUE) - expect_equal(names(fortified), expected_names) - expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), df) - expect_equal(rownames(fortified), rownames(df)) - - fortified <- ggplot2::fortify(stats::princomp(df, center = FALSE, scale = FALSE)) + fortified <- ggplot2::fortify(stats::princomp(df)) expect_equal(is.data.frame(fortified), TRUE) expect_equal(names(fortified), expected_names) expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), df) @@ -207,25 +189,7 @@ test_that('fortify.princomp works for USArrests', { pcs <- c('Comp.1', 'Comp.2', 'Comp.3', 'Comp.4') expected_names <- c(names(USArrests), pcs) - fortified <- ggplot2::fortify(stats::princomp(USArrests, center = TRUE, scale = TRUE)) - expect_equal(is.data.frame(fortified), TRUE) - expect_equal(names(fortified), expected_names) - expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), USArrests) - expect_equal(rownames(fortified), rownames(USArrests)) - - fortified <- ggplot2::fortify(stats::princomp(USArrests, center = FALSE, scale = TRUE)) - expect_equal(is.data.frame(fortified), TRUE) - expect_equal(names(fortified), expected_names) - expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), USArrests) - expect_equal(rownames(fortified), rownames(USArrests)) - - fortified <- ggplot2::fortify(stats::princomp(USArrests, center = TRUE, scale = FALSE)) - expect_equal(is.data.frame(fortified), TRUE) - expect_equal(names(fortified), expected_names) - expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), USArrests) - expect_equal(rownames(fortified), rownames(USArrests)) - - fortified <- ggplot2::fortify(stats::princomp(USArrests, center = FALSE, scale = FALSE)) + fortified <- ggplot2::fortify(stats::princomp(USArrests)) expect_equal(is.data.frame(fortified), TRUE) expect_equal(names(fortified), expected_names) expect_equal(data.frame(fortified[c(1, 2, 3, 4)]), USArrests) @@ -246,30 +210,30 @@ test_that('fortify.dist works for eurodist', { }) test_that('fortify.lfda works for iris', { - library(lfda) - k <- iris[,-5] - y <- iris[,5] - r <- 3 - model <- lfda(k, y, r, metric = "plain") - fortified <- ggplot2::fortify(model) - expect_equal(is.data.frame(fortified), TRUE) - - model <- klfda(kmatrixGauss(k), y, r, metric = "plain") - fortified <- ggplot2::fortify(model) - expect_equal(is.data.frame(fortified), TRUE) - - model <- self(k, y, beta=0.1, r, metric = "plain") - fortified <- ggplot2::fortify(model) - expect_equal(is.data.frame(fortified), TRUE) + skip_on_cran() + library(lfda) + k <- iris[,-5] + y <- iris[,5] + r <- 3 + model <- lfda(k, y, r, metric = "plain") + fortified <- ggplot2::fortify(model) + expect_equal(is.data.frame(fortified), TRUE) + model <- klfda(kmatrixGauss(k), y, r, metric = "plain") + fortified <- ggplot2::fortify(model) + expect_equal(is.data.frame(fortified), TRUE) + model <- self(k, y, beta=0.1, r, metric = "plain") + fortified <- ggplot2::fortify(model) + expect_equal(is.data.frame(fortified), TRUE) }) test_that('autoplot.lfda works for iris', { - k <- iris[,-5] - y <- iris[,5] - r <- 4 - model <- lfda::lfda(k,y,r,metric="plain") - p <- autoplot(model, data=iris, frame = TRUE, frame.colour='Species') - expect_true(is(p, 'ggplot')) + skip_on_cran() + k <- iris[,-5] + y <- iris[,5] + r <- 4 + model <- lfda::lfda(k,y,r,metric="plain") + p <- autoplot(model, data=iris, frame = TRUE, frame.colour='Species') + expect_true(is(p, 'ggplot')) }) test_that('autoplot.acf works', { diff --git a/vignettes/intro_Chinese.Rmd b/vignettes/intro_Chinese.Rmd index 6dfc055..98c8b5a 100644 --- a/vignettes/intro_Chinese.Rmd +++ b/vignettes/intro_Chinese.Rmd @@ -7,7 +7,7 @@ output: word_document [ggfortify](https://github.com/sinhrks/ggfortify) 有着简单易用的统一的界面来用一行代码来对许多受欢迎的R软件包结果进行二维可视化的一个R工具包。这让许多的统计学家以及数据科学家省去了许多繁琐和重复的过程,不用对结果进行任何处理就能以 `{ggplot}` 的风格画出好看的图,大大地提高了工作的效率。 diff --git a/vignettes/plot_dist.Rmd b/vignettes/plot_dist.Rmd index 1d7af54..dfbcf9a 100644 --- a/vignettes/plot_dist.Rmd +++ b/vignettes/plot_dist.Rmd @@ -5,7 +5,7 @@ output: pdf_document ```{r global_options, include=FALSE} diff --git a/vignettes/plot_lm.Rmd b/vignettes/plot_lm.Rmd index de9455b..de522c6 100644 --- a/vignettes/plot_lm.Rmd +++ b/vignettes/plot_lm.Rmd @@ -5,7 +5,7 @@ output: html_document ```{r global_options, include=FALSE} diff --git a/vignettes/plot_pca.Rmd b/vignettes/plot_pca.Rmd index b99bfaf..b23dd4e 100644 --- a/vignettes/plot_pca.Rmd +++ b/vignettes/plot_pca.Rmd @@ -5,7 +5,7 @@ output: html_document ```{r global_options, include=FALSE} @@ -104,7 +104,7 @@ autoplot(pam(iris[-5], 3), frame = TRUE, frame.type = 'norm') # Plotting Local Fisher Discriminant Analysis with ``{lfda}`` package -[``{lfda}``](https://cran.r-project.org/web/packages/lfda/index.html) package supports a set of Local Fisher Discriminant Analysis methods. You can use ``autoplot`` to plot the analysis result as the same manner as PCA. +``{lfda}`` package supports a set of Local Fisher Discriminant Analysis methods. You can use ``autoplot`` to plot the analysis result as the same manner as PCA. Thanks to the kind contribution of [Yuan Tang](https://github.com/terrytangyuan), the author of ``{lfda}`` package. diff --git a/vignettes/plot_surv.Rmd b/vignettes/plot_surv.Rmd index 94d9b0a..046b384 100644 --- a/vignettes/plot_surv.Rmd +++ b/vignettes/plot_surv.Rmd @@ -5,7 +5,7 @@ output: html_document ```{r global_options, include=FALSE} diff --git a/vignettes/plot_ts.Rmd b/vignettes/plot_ts.Rmd index 8ef3f22..251ebf6 100644 --- a/vignettes/plot_ts.Rmd +++ b/vignettes/plot_ts.Rmd @@ -5,7 +5,7 @@ output: html_document ```{r global_options, include=FALSE}