GRPSTATS and datetime columns

Hi, I use grpstats to calculate statistics by different variables often. The new datetime format is very useful and I have converted many of my date handling procedures to utilize datetime arrays. However, when I have a table with a date field in the format of datetime it seems like grpstats can not properly use this field as a grouping statistic. I get the message below, indicating that a datetime field is not a plausible grouping variable format. Is there a way around this? Will this be fixed in the near future?
Error using grp2idx (line 117) A grouping variable must be a categorical, numeric, or logical vector, a cell vector of strings, or a 2D character array.
Thanks for your help, Brian

1 comentario

dpb
dpb el 19 de Mzo. de 2015
I don't have the latest datetime type/class/whatever it actually is; can you cast it to a double a la a traditional date number for the purpose?

Iniciar sesión para comentar.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 19 de Mzo. de 2015

0 votos

Use year, hour, day etc. of the datetime to extract the time component that you want to group by and then call grpstats.

3 comentarios

Brian
Brian el 19 de Mzo. de 2015
Thanks Sean, I do know of a few different work arounds similar to what you are eluding to here, but do you know if this lack of functionality will be addressed in future releases?
Thanks, Brian
Sean de Wolski
Sean de Wolski el 20 de Mzo. de 2015
I don't know and wouldn't be able to discuss future enhancements anyway.
Peter Perkins
Peter Perkins el 22 de Mzo. de 2015
Brian, that's certainly something we're looking into.

Iniciar sesión para comentar.

Categorías

Productos

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 19 de Mzo. de 2015

Comentada:

el 22 de Mzo. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by