| To: | "Walter R. Paczkowski" <dataanalytics@earthlink.net> |
|---|---|
| Subject: | Re: creating a square matrix from a vector |
| From: | David L Lorenz <lorenz@usgs.gov> |
| Date: | Tue, 15 Aug 2006 07:43:21 -0500 |
| Cc: | s-news@lists.biostat.wustl.edu |
| Importance: | Normal |
|
Walt, The lower.tri() function references the lower triangle of a square matrix. To generate your example matrix: mat <- matrix(0, nrow=4, ncol=4) mat[lower.tri(mat)] <- 1:6 mat <- mat + t(mat) If you have a general problem, then you can use the quadratic equation to determine the number of rows and columns from the length of the vector. For a vector of length 325, the matrix must be 26 by 26. Dave -----s-news-owner@lists.biostat.wustl.edu wrote: -----To: s-news@lists.biostat.wustl.edu |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | creating a square matrix from a vector, Walter R. Paczkowski |
|---|---|
| Next by Date: | different linear predictors from coxph and coxme, Emmanuel Tillard |
| Previous by Thread: | creating a square matrix from a vector, Walter R. Paczkowski |
| Next by Thread: | different linear predictors from coxph and coxme, Emmanuel Tillard |
| Indexes: | [Date] [Thread] [Top] [All Lists] |