On Dec 22, 2012, at 2:58 AM, Matthijs Daelman wrote:

> Hi
> 
> I have a time series of measurements: every 10 min. a value was logged.
> 
> The data look like:
> 
> 20100914 08:01     3.74
> 20100914 08:11     3.74
> 20100914 08:21     3.71
> 20100914 08:31     4.39
> 20100914 08:41     3.74
> 
> This data spans several months.
> 
> I would like to group the data per day. In Matlab it is fairly easy to obtain 
> a cell array, of which the first column contains the date of each day, and 
> the second column contains a vector, that in its turn contains all values for 
> the corresponding day.
> 
> That looks like
> 
> 14-9-2010    [3.74 3.74 3.71 4.39 3.74...]
> 15-9-2010    [...]
> and so on.
> 
> Is it possible to create a similar data structure in in R? I was thinking of 
> a data frame, similar to the Matlab's cell array, but it doesn't look like 
> data frames can contain vectors.

That's a surprising conclusion. Vectors are typical components of dataframes.

> Something like a two dimensional list would do the trick, I believe, but does 
> that exist?

A dataframe _is_ a two-dimensional list.

You should probably explain what you are trying to do, since there is very 
possibly a better way of structuring this problem without recasting the data 
into a "wide format". Most of the data processing in R is handled very well 
without such a strategy.

If you wanted to proceed despite my misgivings, then there are several 
functions such as `split`, `tapply` and `by` that could allow you to segregate 
such data. It's best to use dput to present the data since console output is 
often ambiguous as to the underlying data structures.
>From what you have offered it's not clear that you have yet done the data 
>input processing.

-- 

David Winsemius
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
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