Perform correlation and linear regression for a data.frame automatically

Share:

Description

Perform correlation and linear regression for a data.frame automatically

Usage

1
2
3
4
5
6
7
mycor(x, ..., digits)

## Default S3 method:
mycor(x, ..., digits = 3)

## S3 method for class 'formula'
mycor(formula, data, ..., digits = 3)

Arguments

x

A data.frame.

...

further arguments to be passed to cor.test.

digits

integer indicating the number of decimal places (round) or significant digits (signif) to be used.

formula

a formula of the form ~ u + v, where each of u and v are numeric variables giving the data values for one sample. The samples must be of the same length.

data

A data.frame

mycor

Object to mycor

Value

mycor returns as object of class "mycor"

The function summary is used to print a summary of the result. The function plot is used to plot the results using pairs and parallelplot.

An object of class "mycor:" is a list containing at least following components:

df

a data.frame

select

logical vectors returns if columns of df is.numeric

out

a list of class "htest" from cor.test between the last paired samples in a data.frame.

r

a matrix consist of r values from cor.test between all pairs of numeric data from a data.frame

p

a matrix consist of p values from cor.test between all pairs of numeric data from a data.frame

slope

a matrix consist of slope values from lm between all pairs of numeric data from a data.frame

intercept

a matrix consist of intercept values from lm between all pairs of numeric data from a data.frame

Methods (by class)

  • default: for class data.frame

  • formula: for class "formula"

Examples

1
2
3
4
5
6
7
8
9
out=mycor(iris)
 plot(out)
 plot(out, groups=Species)
 plot(out,type=2,groups=species)
 plot(out,type=4,groups=species)
 out1=mycor(~mpg+disp+wt+hp,data=mtcars,alternative="greater",methods="kendall",
            conf.level=0.95)
 plot(out1,type=3)
 plot(out1,type=4,groups=cyl)