I'm very new to using R and am really struggling with the below - any help would be gratefully received.
I need to calculate the total mark from an exam and coursework ( x&y ) and need to use Logical Operators in R to calculate this based on the following criteria.
If exam mark is >=50 then the final mark is 0.2x * 0.7y
If exam mark is <50 > 70 then the final mark is y+10
If exam mark is <50 <70 then the final mark is R.
My problem is that I need to put all 3 criteria above together in one string in R so that whatever value x and y has the 'program' I create will give the corresponding final mark.
I've tried numerous ways of doing this but R just errors everytime. I'm positive it's a coding error (user error) but despite googling; trawling through reference books I just can't get it to work.
I think the problem is I understand how the logical operators work - but not how to get the correct formula for final mark to be carried out if the logical operator gives TRUE and also how to put this in one program
My most recent attempt is as below:
finalmark <- ((y>=50) <- (0.2*x+0.8*y)) |((y<=50 & x>70) <- (y+10)) |((y<=50 & x<70) <- (y))
I've been trying to get this right for the last 4 days - so if anyone can help me or point me in the correct direction I would be really grateful!