[R] Returning data in matrix form

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Jan 19 21:23:03 CET 2004


Jonathan Baron <baron at psych.upenn.edu> writes:

> On 01/19/04 19:27, Laura Quinn wrote:
> >I am trying to perform the following calculation for a very
> >large time series data set:
> >
> >x<-unit(length*data.frame.a*data.frame.b,"cm")
> >
> >data.frame.a and data.frame.b are of the same dimension, and I wish to
> >perform the calculation in one step so that "x" is returned as a
> >matrix/data.frame of equal dimension.
> 
> Sounds like mapply() would be useful.  It works on columns of
> data frames.  The default is "simplify=TRUE" so it will try to
> return a vector or matrix.

Maybe, but what was ever wrong with

length*as.matrix(data.frame.a)*as.matrix(data.frame.b) 

or, possibly, as.data.frame thereof?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list