Skip to content
Back to formatted view

Raw Message

Message-ID: <51559747020000CB000DE1D8@smtp.medicine.umaryland.edu>
Date: 2013-03-29T17:29:43Z
From: John Sorkin
Subject: Make a matrix from two lists

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.