[R] Make a matrix from two lists

John Sorkin JSorkin at grecc.umaryland.edu
Fri Mar 29 18:29:43 CET 2013


I am trying to write a function that makes a matrix out of two lists. As you will see run running the function below, the result is NOT a matrix but rather a list. Can anyone tell me what I am doing wrong?
Thanks,
John
 
test <- function(one,two) {
  cat("List One=",one,"\n")
  cat("List Two=",two,"\n")
  cat("Should be a matrix, but is not",matrix(cbind(one,two)),"\n")
 }
x <- c(1,2,3)
y <- c(11,22,33)
test(x,y)
 
 
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
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)
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information.  Any unauthorized use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. 


More information about the R-help mailing list