Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagonal matrix #55

Merged
merged 6 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: corrr
Type: Package
Version: 0.2.1.9000
Version: 0.3.0.9999
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this back to 0.2.1.9000. I tend to work as follows:

  • Start with dev version (ending .9000) and remain on it until a CRAN release
  • For CRAN release change to next version (e.g., 0.3.0)
  • Once on CRAN, flag release on GitHub and change to dev version on next change (by appending .9000)

I tend to follow advice here.

Which reminded me, the next version should actually be 1.0.0 (due to backward compatible issue). Regardless, we'll wait until ready for a CRAN release.

Title: Correlations in R
Description: A tool for exploring correlations.
It makes it possible to easily perform routine tasks when
Expand All @@ -9,7 +9,8 @@ Description: A tool for exploring correlations.
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("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
Expand All @@ -31,4 +32,4 @@ Imports:
tibble (>= 1.1),
ggrepel (>= 0.6.5),
methods (>= 3.4.3)
VignetteBuilder: knitr
VignetteBuilder: knitr
120 changes: 62 additions & 58 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,63 @@
# 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`.

## 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

- 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.3.0.9999
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will also need to change this back


## 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`.

## 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

- 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

- 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
54 changes: 27 additions & 27 deletions man/as_cordf.Rd

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

46 changes: 23 additions & 23 deletions man/as_matrix.Rd

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

Loading