R/readMoments.R

Defines functions read.moments readMoments

Documented in read.moments readMoments

# last modified 2011-087-07 by J. Fox

read.moments <- function(...){
	.Deprecated("readMoments", package="sem")
	readMoments(...)
}

readMoments <- function(file="", diag=TRUE, 
        names=as.character(paste("X", 1:n, sep=""))){
    elements <- scan(file=file)
    m <- length(elements)
    d <- if (diag) 1 else -1
    n <- floor((sqrt(1 + 8*m) - d)/2)
    if (m != n*(n + d)/2) 
        stop("wrong number of elements (cannot make square matrix)")
    if (length(names) != n) stop("wrong number of variable names")
    X <- diag(n)
    X[upper.tri(X, diag=diag)] <- elements
    rownames(X) <- colnames(X) <- names
    t(X)
    }
    

Try the sem3 package in your browser

Any scripts or data that you put into this service are public.

sem3 documentation built on May 2, 2019, 5:48 p.m.