필터 지우기
필터 지우기

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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by