Create a Loop Based on Filter Function

Hi,

I am having problems at creating a loop for applying a function to different participant data in a data frame based on filter function (X1:X30, 30 times), and find the minimum value for the results. Follows are all the codes I want to put into the loop.

I need to create a new column based on Participant name in the profile data frame every time.

I need to do filter every time after with function based on Participants (X1,X2,X3...X30)

profile$X1 <- with(ori %>% filter(Participant == 'X1'),
mapply(loglikelihood_V1,
profile$gamma,
profile$epsilon,
profile$lambda,
MoreArgs=list(A1_payoff = A1_payoff,
A2_payoff = A2_payoff,
B1_payoff = B1_payoff,
B2_payoff = B2_payoff,
A1_prob = A1_prob,
A2_prob = A2_prob,
B1_prob = B1_prob,
B2_prob = B2_prob,
Choice = Choice)))

I need to find a minimum value every time and put them in a new data frame

profile[which.min(profile$loglikelihood_x1)]

Thank you very much for helpingļ¼

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