Write a Function to Calculate Combination of Numbers

I have marks for 5 modules (77,75.35,64.84,71.15), which count 30 credit for 1 (77) and 15 credit each for the rest. I need 120 credits in total. And I want to see all the combination of the marks for the left credits (neuro, modelling, cognition) to make my total average higher than 70. I'm trying to write a function, but not sure how to do it. In the function, I want to put a random number x and generate all the combinations that make the average higher than x. Also, is it possible to put the results to the data frame 'mark' automatically?

mark <- data.frame(Module = c('Behavioural Micro', 'Issues in Psychology', 'Methods and Analysis in Behavioural Science', 'Nudging'), Mark = c(77,75.35,64.84,71.15))

function (x){
mark_has <- sum (mark$Mark+mark$Mark[1])/15
Neuro <- runif(1,0,100)
Modelling <- runif(1,0,100)
Cognition <- runif(1,0,100)

mark_has + Neuro + Modelling + Cognition)/8 > x

Thank you very much for your helping.

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