Categorical2Num in a table

3 ビュー (過去 30 日間)
BingoIngo
BingoIngo 2019 年 5 月 9 日
回答済み: Peter Perkins 2019 年 5 月 14 日
I have a table with categorical data in it. In order to calculate average etc. I need to convert it to num. Does anyone know the syntax?
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 5 月 9 日
YourTable.NewVariable = double(YourTable.CategoricalVariable)
It is possible to replace the variable but you have to build a table to do it because of the change of data type.
Are you sure you need numeric? findgroups will probably provide you with everything you need in practice.

サインインしてコメントする。

回答 (1 件)

Peter Perkins
Peter Perkins 2019 年 5 月 14 日
If you are computing the average of a numeric variable using a cate3gorical variable to group your data, then you should not need to convert anything.
But your description sounds like you are trying to compute the average of a categorical variable. That's a contradiction in terms. It's like computing the mean of text data. Mode, sure (in which case you don't need to convert), median, yes, if it's ordinal. Mean? Something is wrong.

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by