Use loops to calculate mean, slope, and range of data

For context, I have continuous rating data from 30 different participants from a study. So basically participants listened to some audio clips and provided their continuous ratings. Right now I have one data frame for each participant with all of their continuous ratings for each clip in a distinct column (attached image below). I know I need to convert this so that each observation has its own cell in the column. So I did this, but had to create a data frame for the participant's rating for each clip (as the clips are different lengths in duration and thus have a different number of observations - and R wouldn't let me combine data frames with a different number of observations). What I'm hoping to do with this data is use loops to cycle through the data frame and calculate the overall mean, range, and slope for each participant and put this in specific columns in a new data frame. So in the new file I'd have a participant column, mean column, range column, and slope column. How would I set up my code to accomplish this (including taking into account that the clips have a different number of observations within participants as the durations are different)?

I apologize if anything is confusing, and please let me know if anything needs clarification. I've just been banging my head against a wall for a while trying to figure out how to do it.

Hi, can you provide a reproducible example? It will make it easier for others to help. A screenshot is not helpful.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.