MATLAB Answers

How to group multiple data points (rows) from the same person into one row (containing the average) in a table?

조회 수: 1(최근 30일)
Montana Jackson
Montana Jackson 2021년 5월 7일
편집: Asvin Kumar 2021년 5월 11일
Hi, I have a dataset that has individual rows for the reaction time to a computer-based task for different individuals (participant ID). The ParticipantID column has multiple participants in it, the first one being 12131. Additionally, they repeat this task on more than one occasion (Repeat column). I would like to create a table that has the mean ResponseTime per participant per repeat. So in the end I would have a table with 'ParticipantID' 'Repeat' 'ResponseTime' as the variables, where each participant would have repeats 1, 2, 3 etc... currently where the RepeatNumber is the same (i.e. always number 1 in this example), this shows the response to multiple 'trials' within the first 'repeat' of the task and I want to group them together to get the mean response time for the first repeat of this task. Could anyone help me with the code please?
I am very new to this, so any help would be much appreciated. Many thanks!
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 5월 7일
It would help if you posted your data along with the question.
Also, you should s at least try to develop some code for a solution. Then, post what you've done along with questions on specific issues you are struggling with. Your question, as posted, amount to this: here's a snippet of my data, here's what I want to do, show me -- not good!

댓글을 달려면 로그인하십시오.

채택된 답변

Asvin Kumar
Asvin Kumar 2021년 5월 10일
편집: Asvin Kumar 2021년 5월 11일
This seems like just the use case for findgroups and splitapply. Both the linked pages have good examples that should help you get started.
The following example shows how to use these two functions on a table: Split Table Data Variables and Apply Functions
You can also have a look at this page which explains the generic split-apply-combine workflow: Grouping Variables to Split Data.

추가 답변(0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by