Learn R Programming

lessR (version 2.5)

corRead: Read Specified Correlation Matrix into an R Matrix Named mycor

Description

Abbreviation: rad.cor

Read a correlation matrix into R. The resulting matrix is named mycor. All coefficients for each variable must be on one row. No variable names are in the file to be read.

Usage

corRead(ref=NULL, names=NULL)

rad.cor(...)

Arguments

ref
File reference, either omitted to browse for the data file, or a full path name or web URL, included in quotes. A URL begins with http://.
names
The names of the variables in the matrix.
...
Parameter values.

Details

Read a correlation, or any square, matrix into R. The resulting matrix is named mycor. All coefficients for each variable must be on one row. No variable names are in the file to be read. The coefficients within each row, that is, for a single variable, are delimited by a white space, such as one or more blanks.

The standard R function used to read the matrix is read.table.

By default the variables are named V1, V2, etc. If the names option is invoked, then the specified names are attached to the respective rows and columns of the matrix. Here it may be convenient to name the variables with the lessR function to.

The alternative is to calculate the correlations from the data, such as with the lessR function cr or the standard R function cor.

See Also

cr, read.table.

Examples

Run this code
# browse for the data file because ref is omitted
# name the variables with the lessR function to
# corRead(names=to("m",20))

# abbreviated form
# read a matrix with 4 variables and specify the names
# rad.cor(names=c("m06","m07","m09","m10"))

Run the code above in your browser using DataLab