Automatic Correlation and Regression Test in a 'data.frame'

Perform correlation and linear regression test among the numeric fields in a data.frame automatically and make plots using pairs or lattice::parallelplot.

title: "package mycor" author: "Keon-Woong Moon [email protected]" date: "2014-10-01" output: html_document

This package is for automatic correlation and linear regeression test of a data.frame like cor() in R. Function cor() get r values from a numeric vector, matrix or data.frame, but it does not work in a data.frame consist of numeric, factor or character variables.
If you wanted to get p values as well as r values, you should use cor.test instead of cor. But cor.test can deal with only one pair of numeric vectors of the same length, neither a matrix nor a data.frame. Furthermore, if you wanted to get the slope and intercept of simple linear regression line of xyplot, you had to perform lm test for every pairs of numeric variables of the data.frame.

The main function of this package is mycor(). It returns an object of S3 class "mycor" consist of r values and p values as well as slope and intercept from lm() test. Plot "mycor" object is very simple and convenient. Plot.mycor function has four types of plots.


$ r value by Pearson's product-moment correlation 

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length        1.000      -0.118        0.872       0.818
Sepal.Width        -0.118       1.000       -0.428      -0.366
Petal.Length        0.872      -0.428        1.000       0.963
Petal.Width         0.818      -0.366        0.963       1.000

$ p value ( two.sided )

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length        0.000       0.152            0           0
Sepal.Width         0.152       0.000            0           0
Petal.Length        0.000       0.000            0           0
Petal.Width         0.000       0.000            0           0

plot of chunk unnamed-chunk-1


plot of chunk unnamed-chunk-1


plot of chunk unnamed-chunk-1


mycor 0.1.1


  • Added missing imports and S3 method registration

mycor 0.1.0


  • new function "mycor" which automatically perform correlation and linear regression test for a data.frame and return an object of S3 class "mycor"

  • new generic function "mycor.formula" makes an object of calss "mycor" from formula

  • new function plot.mycor which has four predefine plots based on pairs() and lattice::parallelplot

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.1 by Keon-Woong Moon, 4 years ago

Browse source code at

Authors: Keon-Woong Moon [aut, cre]

Documentation:   PDF Manual  

CC0 license

Imports lattice

Suggests knitr, testthat

Imported by ggiraphExtra.

See at CRAN