[R] Printing a list of simultaneous equations

Sorkin, John j@ork|n @end|ng |rom @om@um@ry|@nd@edu
Fri Jan 18 13:02:09 CET 2019


I am trying to print a list of equations in an easily readable form. At this time all I can get is  a series of characters enclosed in quotation marks rather than equations with numbers and equal signs. What I get is


    y     equalsigns x   z
eq1 "0.5" "="        "1" "2"
eq2 "4"   "="        "2" "3"


When what I want is

          y         x   z

eq1  0.5  =  1   2
eq2  4.0  =  2   3


I am enclosing my R code below:

# Create matrix of  coefficients of independent variables.
a  <- matrix(c(1,2,2,3),nrow=c(2,2),byrow=TRUE)
dimnames(a)<-list(c("eq1","eq2"),c("x","z"))
cat("Matrix of independent variables\n")
a

# Create vector of dependent variables.
b <- matrix(c(0.5,4.0),nrow=c(2,1))

dimnames(b)<-list(c("eq1","eq2"),c("y"))
cat("Vector of dependent variables","\n")
b

cat("System of equations to be solved")
equalsigns <- c("=","=")
cbind(b,equalsigns,a)




Thank you,

John





John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


	[[alternative HTML version deleted]]



More information about the R-help mailing list