How do I find the average for a grade? In R

2

I need to add 2 notes typed to find the final average in R (Nota1 + 2*Nota2)/3 but I do not know how to do the final calculation for the script to work without error

print("Escreva seu nome") 

W<-scan(what="character",nmax=1)

print("Qual a nota1?")

X<-scan(what="character",nmax=1)

X<-as.numeric(X)

print("Qual a nota2?")

Y<-scan(what="character",nmax=1)

Y<-as.numeric(Y)

Line of code I do not know.

if (Z<6) {print("Faça a G3.")} else {print("Aprovado.")}

RGui
    
asked by anonymous 24.08.2017 / 19:13

1 answer

2

To do the arithmetic mean in R we use the mean(c[x]) function that receives a list of numbers. But in your case you would have to do something like:

// Para X = 10 e Y = 20
Z <- (X + 2*Y)/3

The result will be: > [1] 16.66667

    
24.08.2017 / 19:32