Skip to content

Commit

Permalink
Merge pull request #55 from cimentadaj/diagonal_matrix
Browse files Browse the repository at this point in the history
Diagonal matrix
  • Loading branch information
drsimonj authored Apr 2, 2018
2 parents b594f63 + af1f922 commit d55b275
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 584 deletions.
77 changes: 39 additions & 38 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
Package: corrr
Type: Package
Version: 0.2.1.9000
Title: Correlations in R
Description: A tool for exploring correlations.
It makes it possible to easily perform routine tasks when
exploring correlation matrices such as ignoring the diagonal,
focusing on the correlations of certain variables against others,
or rearranging and visualising the matrix in terms of the
strength of the correlations.
Authors@R: c(
person("Simon", "Jackson", email = "drsimonjackson@gmail.com", role = c("aut", "cre"))
)
URL: https://github.com/drsimonj/corrr
BugReports: https://github.com/drsimonj/corrr/issues
Depends:
R (>= 3.3.0),
dplyr (>= 0.5.0)
LazyData: yes
License: MIT + file LICENSE
RoxygenNote: 6.0.1
Suggests:
testthat (>= 1.0.2),
knitr (>= 1.13),
rmarkdown (>= 0.9.6),
dbplyr (>= 1.2.1)
Imports:
magrittr (>= 1.5),
tidyr (>= 0.5.1),
ggplot2 (>= 2.2.0),
seriation (>= 1.2-0),
lazyeval (>= 0.2.0),
purrr (>= 0.2.2),
tibble (>= 1.1),
ggrepel (>= 0.6.5),
methods (>= 3.4.3),
rlang(>= 0.2.0)
VignetteBuilder: knitr
Package: corrr
Type: Package
Version: 0.2.1.9000
Title: Correlations in R
Description: A tool for exploring correlations.
It makes it possible to easily perform routine tasks when
exploring correlation matrices such as ignoring the diagonal,
focusing on the correlations of certain variables against others,
or rearranging and visualising the matrix in terms of the
strength of the correlations.
Authors@R: c(
person("Simon", "Jackson", email = "drsimonjackson@gmail.com", role = c("aut", "cre")),
person("Jorge", "Cimentada", email = "cimentadaj@gmail.com", role = c("ctb"))
)
URL: https://github.com/drsimonj/corrr
BugReports: https://github.com/drsimonj/corrr/issues
Depends:
R (>= 3.3.0),
dplyr (>= 0.5.0)
LazyData: yes
License: MIT + file LICENSE
RoxygenNote: 6.0.1
Suggests:
testthat (>= 1.0.2),
knitr (>= 1.13),
rmarkdown (>= 0.9.6),
dbplyr (>= 1.2.1)
Imports:
magrittr (>= 1.5),
tidyr (>= 0.5.1),
ggplot2 (>= 2.2.0),
seriation (>= 1.2-0),
lazyeval (>= 0.2.0),
purrr (>= 0.2.2),
tibble (>= 1.1),
ggrepel (>= 0.6.5),
methods (>= 3.4.3),
rlang(>= 0.2.0)
VignetteBuilder: knitr
86 changes: 43 additions & 43 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# Generated by roxygen2: do not edit by hand

S3method(Ops,cor_df)
S3method(as_matrix,cor_df)
S3method(correlate,default)
S3method(correlate,tbl_sql)
S3method(fashion,data.frame)
S3method(fashion,default)
S3method(fashion,matrix)
S3method(focus_,cor_df)
S3method(focus_if,cor_df)
S3method(focus_if,default)
S3method(network_plot,cor_df)
S3method(network_plot,default)
S3method(rearrange,cor_df)
S3method(rplot,cor_df)
S3method(rplot,default)
S3method(shave,cor_df)
S3method(stretch,cor_df)
export(as_cordf)
export(as_matrix)
export(correlate)
export(fashion)
export(first_col)
export(focus)
export(focus_)
export(focus_if)
export(network_plot)
export(pair_n)
export(rearrange)
export(rplot)
export(shave)
export(stretch)
import(dplyr)
import(ggplot2)
import(rlang)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(purrr,map)
importFrom(purrr,map_df)
importFrom(stats,"dist")
importFrom(tibble,as.tibble)
importFrom(tibble,tibble)
# Generated by roxygen2: do not edit by hand
S3method(Ops,cor_df)
S3method(as_matrix,cor_df)
S3method(correlate,default)
S3method(correlate,tbl_sql)
S3method(fashion,data.frame)
S3method(fashion,default)
S3method(fashion,matrix)
S3method(focus_,cor_df)
S3method(focus_if,cor_df)
S3method(focus_if,default)
S3method(network_plot,cor_df)
S3method(network_plot,default)
S3method(rearrange,cor_df)
S3method(rplot,cor_df)
S3method(rplot,default)
S3method(shave,cor_df)
S3method(stretch,cor_df)
export(as_cordf)
export(as_matrix)
export(correlate)
export(fashion)
export(first_col)
export(focus)
export(focus_)
export(focus_if)
export(network_plot)
export(pair_n)
export(rearrange)
export(rplot)
export(shave)
export(stretch)
import(dplyr)
import(ggplot2)
import(rlang)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(purrr,map)
importFrom(purrr,map_df)
importFrom(stats,"dist")
importFrom(tibble,as.tibble)
importFrom(tibble,tibble)
128 changes: 66 additions & 62 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
# corrr 0.2.1.9000

## New Functions

- `as_cordf` will coerce lists or matrices into correlation data frames if possible.
- `focus_if` enables conditional variable selection.


## New Functionality

- Can use arithmetic operators (e.g., `+` or `-`) with correlation data frames.
- Plotting functions (`rplot` and `network_plot`) will attempt to coerce objects to a correlation data frame (via `as_cordf`) if needed, making it possible to directly use these functions with other square-matrix-like objects.
- `repel` option added to `network_plot` (default = `TRUE`).
- `curved` option added to `network_plot` (default = `TRUE`).
- `correlate()` now prints a message about the `method` and `use` parameters. Can be silenced with `quiet = TRUE`.
- `correlate()` now supports data frame with a SQL back-end (`tbl_sql`)

## Fixes

- When `legend = TRUE` (now the default setting), `rplot` and `network_plot` generate a single, unlabelled legend referring to the size of the correlations.

## Other

- `correlate()` is now an S3 method so that it can adapt to `x`'s object type.

- During the development of this version, ggplot v2.2.0 was released. Many changes in the plotting functions have been made to handle new features in the updated version of ggplot2.

# corrr 0.2.1

## New Functionality

- Can keep leading zeros when using `fashion()` with new argument `leading_zeros = TRUE`.
- New optional arguments added to plotting functions, `network_plot()` and `rplot()`:
- `legend` to display a legend mapping correlations to size and colour.
- `colours` (or `colors`) to change colours in plot.

## Fixes

- `network_plot()` no longer plots wrong colours if only positive correlations are included.
- Colour scheme for `network_plot()` changed to match `rplot()`.
- Other bug fixes.

# corrr 0.2.0

## New Functions

- `network_plot()` the correlations.
- `focus_()` for standard evaluation version of `focus()`.

## New Functionality

- `fashion()` will now attempt to work on any object (not just `cor_df`), making it useful for printing any data frame, matrix, vector, etc.
- `print_cor` argument added to `rplot()` to overlay the correlations as text.

## Other

- `na_omit` argument in `stretch()` changed to `na.rm` to match `gather_()`.
- Bug fixes.
- Improvements.

# corrr 0.1.0

# corrr 0.2.1.9000

## Small breaking changes

The `diagonal` argument of `as_matrix` and `as_matrix.cor_df` is now an optional argument rather than set to `1` by default [#52](https://github.com/drsimonj/corrr/issues/52)

## New Functions

- `as_cordf` will coerce lists or matrices into correlation data frames if possible.
- `focus_if` enables conditional variable selection.

## New Functionality

- Can use arithmetic operators (e.g., `+` or `-`) with correlation data frames.
- Plotting functions (`rplot` and `network_plot`) will attempt to coerce objects to a correlation data frame (via `as_cordf`) if needed, making it possible to directly use these functions with other square-matrix-like objects.
- `repel` option added to `network_plot` (default = `TRUE`).
- `curved` option added to `network_plot` (default = `TRUE`).
- `correlate()` now prints a message about the `method` and `use` parameters. Can be silenced with `quiet = TRUE`.
- `correlate()` now supports data frame with a SQL back-end (`tbl_sql`)

## Fixes

- When `legend = TRUE` (now the default setting), `rplot` and `network_plot` generate a single, unlabelled legend referring to the size of the correlations.

## Other

- `correlate()` is now an S3 method so that it can adapt to `x`'s object type.

- During the development of this version, ggplot v2.2.0 was released. Many changes in the plotting functions have been made to handle new features in the updated version of ggplot2.

# corrr 0.2.1

## New Functionality

- Can keep leading zeros when using `fashion()` with new argument `leading_zeros = TRUE`.
- New optional arguments added to plotting functions, `network_plot()` and `rplot()`:
- `legend` to display a legend mapping correlations to size and colour.
- `colours` (or `colors`) to change colours in plot.

## Fixes

- `network_plot()` no longer plots wrong colours if only positive correlations are included.
- Colour scheme for `network_plot()` changed to match `rplot()`.
- Other bug fixes.

# corrr 0.2.0

## New Functions

- `network_plot()` the correlations.
- `focus_()` for standard evaluation version of `focus()`.

## New Functionality

- `fashion()` will now attempt to work on any object (not just `cor_df`), making it useful for printing any data frame, matrix, vector, etc.
- `print_cor` argument added to `rplot()` to overlay the correlations as text.

## Other

- `na_omit` argument in `stretch()` changed to `na.rm` to match `gather_()`.
- Bug fixes.
- Improvements.

# corrr 0.1.0

>>>>>>> b594f6382f9c21be8ae3b1c3720e76ad2453aefb
- First corrr release!
8 changes: 4 additions & 4 deletions R/cor_df.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Utility --------------------------------------------------------------

#' @export
as_matrix.cor_df <- function(x, diagonal = 1) {
as_matrix.cor_df <- function(x, diagonal) {

# Separate rownames
row_names <- x$rowname
x %<>% dplyr::select_("-rowname")
# Return diagonal to 1
diag(x) <- diagonal
if (!missing(diagonal)) diag(x) <- diagonal

# Convert to matrix and set rownames
class(x) <- "data.frame"
Expand Down Expand Up @@ -43,7 +43,7 @@ shave.cor_df <- function(x, upper = TRUE) {
rearrange.cor_df <- function(x, method = "PCA", absolute = TRUE) {

# Convert to original matrix
m <- x %>% as_matrix()
m <- x %>% as_matrix(diagonal = 1)

if (absolute) {
m %<>% abs()
Expand Down Expand Up @@ -218,7 +218,7 @@ network_plot.cor_df <- function(rdf,
if (!missing(colors))
colours <- colors

rdf %<>% as_matrix()
rdf %<>% as_matrix(diagonal = 1)
distance <- sign(rdf) * (1 - abs(rdf))

# Use multidimensional Scaling to obtain x and y coordinates for points.
Expand Down
2 changes: 1 addition & 1 deletion R/utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ pair_n <- function(x, y = NULL) {
#' @examples
#' x <- correlate(mtcars)
#' as_matrix(x)
as_matrix <- function(x, diagonal = 1) {
as_matrix <- function(x, diagonal) {
UseMethod("as_matrix")
}
36 changes: 18 additions & 18 deletions corrr.Rproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Loading

0 comments on commit d55b275

Please sign in to comment.