Skip to content

Commit

Permalink
Merge pull request #81 from sinhrks/v010
Browse files Browse the repository at this point in the history
REL: v0.1.0
  • Loading branch information
sinhrks committed Nov 30, 2015
2 parents 7f06d89 + 3851ed8 commit d3cf5fb
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 75 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> and Yuan Tang
<[email protected]>
Maintainer: Masaaki Horikoshi <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
NEWS
=====================

ggfortify dev version
---------------------
ggfortify v0.1.0
----------------

- Compatible with ggplot2 v1.1.0
- Support glmnet
Expand Down
2 changes: 2 additions & 0 deletions R/fortify_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {

Expand Down
4 changes: 2 additions & 2 deletions R/geom.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/plotlib.R
Original file line number Diff line number Diff line change
Expand Up @@ -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'))))
}


Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -44,7 +44,7 @@ This covers following classes:
- ``stats::acf``
- ``stats::ar``
- ``stats::Arima``
- ``stats::cmdscale`` (inference, see the `doc <http://rpubs.com/sinhrks/plot_mds>`_)
- ``stats::cmdscale`` (inference)
- ``stats::decomposed.ts``
- ``stats::density``
- ``stats::factanal``
Expand Down
2 changes: 2 additions & 0 deletions man/fortify.lfda.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 23 additions & 59 deletions tests/testthat/test-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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', {
Expand Down
2 changes: 1 addition & 1 deletion vignettes/intro_Chinese.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ output: word_document

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Introduction to ggfortify package}
%\VignetteIndexEntry{Introduction to ggfortify package (Chinese)}
-->

[ggfortify](https://github.com/sinhrks/ggfortify) 有着简单易用的统一的界面来用一行代码来对许多受欢迎的R软件包结果进行二维可视化的一个R工具包。这让许多的统计学家以及数据科学家省去了许多繁琐和重复的过程,不用对结果进行任何处理就能以 `{ggplot}` 的风格画出好看的图,大大地提高了工作的效率。
Expand Down
2 changes: 1 addition & 1 deletion vignettes/plot_dist.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output: pdf_document

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Introduction to ggfortify package}
%\VignetteIndexEntry{Plotting Probability Distributions}
-->

```{r global_options, include=FALSE}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/plot_lm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output: html_document

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Introduction to ggfortify package}
%\VignetteIndexEntry{Plotting Diagnostics for LM and GLM}
-->

```{r global_options, include=FALSE}
Expand Down
4 changes: 2 additions & 2 deletions vignettes/plot_pca.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output: html_document

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Introduction to ggfortify package}
%\VignetteIndexEntry{Plotting PCA, clustering, LFDA and MDS results}
-->

```{r global_options, include=FALSE}
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion vignettes/plot_surv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output: html_document

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Introduction to ggfortify package}
%\VignetteIndexEntry{Plotting Survival Curves}
-->

```{r global_options, include=FALSE}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/plot_ts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output: html_document

<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Introduction to ggfortify package}
%\VignetteIndexEntry{Plotting Time Series}
-->

```{r global_options, include=FALSE}
Expand Down

0 comments on commit d3cf5fb

Please sign in to comment.