[R] How to make matrix missing data 0

David Winsemius dwinsemius at comcast.net
Thu Jul 7 21:28:44 CEST 2011


On Jul 7, 2011, at 3:21 PM, xin123620 wrote:

> Dear All,
>
> I am trying to analysis traffic data with one timestamp column and  
> speed
> column. This data set contains six years data; for each year, I want  
> to make
> a matrix in (day of the year) * (hour)
>         0  1  2   . . . 23
> 1
> 2
> .
> .
> 365
>
> However random day's record is missing(e.g. there are 40 missing  
> records in
> 2005 data set), when I tried to use tapply function, matrix came out  
> is
> 326*23 table and there were no N/A remind me which day is missing  
> data.
>
> Can you give some hints to make a 366*24 table please? Any help is
> appreciated.

More detail about what your data looks like and how you are importing  
it from file would be helpful.

(And please do read the Posting Guide where this request is spelled  
out in greater detail and where advice about successful attachment of  
datasets can be found.)
>
>
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list