corRead | R Documentation |
Abbreviation: rd.cor
A wrapper for base~R read.table
. Read a correlation matrix into R. All coefficients for each variable must be on one physical row. No variable names are in the file to be read.
corRead(from=NULL, var_names=NULL, ...)
rd.cor(...)
from |
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 |
var_names |
The names of the variables in the matrix. |
... |
Parameter values for base R |
Read a correlation, or any square, matrix into R. 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 that reads the matrix is read.table
.
By default the variables are named X1, X2, etc. If the var_names
option is invoked, then the specified names refer 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 Correlation
or the standard R function cor
.
David W. Gerbing (Portland State University; gerbing@pdx.edu)
Gerbing, D. W. (2014). R Data Analysis without Programming, Chapter 8, NY: Routledge.
Correlation
, read.table
.
# browse for the data file because ref is omitted
# name the variables with the lessR function to
# mycor <- corRead(var_names=to("m",20))
# abbreviated form
# read a matrix with 4 variables and specify the names
# mycor <- rd.cor(var_names=c("m06","m07","m09","m10"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.