Don't use the default print method then. When you type an expression alone at 
the console it uses a print function to convert the result to characters for 
output. The default print method for matrices of character uses quotes to show 
the exact contents of each character string.

Convert the matrix to a single string using  paste for each line, then paste 
the lines together with newlines, then cat the string to the console. You will 
probably find that converting the individual elements into strings with uniform 
string length (using sprintf?) as you add them into the matrix makes the final 
output look better.

On January 18, 2019 4:02:09 AM PST, "Sorkin, John" <jsor...@som.umaryland.edu> 
wrote:
>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]]
>
>______________________________________________
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to