フィルターのクリア

Counting outcomes of names

2 ビュー (過去 30 日間)
Ruben Moreno
Ruben Moreno 2022 年 5 月 12 日
コメント済み: Ruben Moreno 2022 年 5 月 12 日
Hi, i have a collumn of names of investors in a large dataset and im trying to extract the occurance of every investor. A large quanitity have a combination of investors, meaning there are several names in one cell, so they would only be counted once if i were to count them alone. Is there any way to count all names, even in combination with others?

採用された回答

Matt J
Matt J 2022 年 5 月 12 日
編集済み: Matt J 2022 年 5 月 12 日
Something like this, perhaps?
investors=["Sam";"Joe";"Sam and Joe"]
investors = 3×1 string array
"Sam" "Joe" "Sam and Joe"
contains(investors,"Sam")
ans = 3×1 logical array
1 0 1
  8 件のコメント
Matt J
Matt J 2022 年 5 月 12 日
The error is not coming from code that you've shown us (or that I've shown you).
Ruben Moreno
Ruben Moreno 2022 年 5 月 12 日
Nvm, i fixed it. It worked now, Wow. thank you very much!

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

その他の回答 (1 件)

Stephen23
Stephen23 2022 年 5 月 12 日
編集済み: Stephen23 2022 年 5 月 12 日
str = ["Sam";"Joe";"TPG, Sam, Joe";"TPG, Joe"]
str = 4×1 string array
"Sam" "Joe" "TPG, Sam, Joe" "TPG, Joe"
spl = regexp(str,',','split');
[uni,~,idx] = unique(strtrim([spl{:}]));
cnt = histcounts(idx);
[uni;cnt]
ans = 2×3 string array
"Joe" "Sam" "TPG" "3" "2" "2"
  1 件のコメント
Ruben Moreno
Ruben Moreno 2022 年 5 月 12 日
i figured the problem out. But i have a follow up question, I want to use the information i gained. Count of every investors frequency. to add a indication for experience in the original dataset. Creating a dummy for investors observations > 100 and 0 for the rest.

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

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by