How to add new columns (new calculation) using R STUDIO?

How to add new columns (new calculation) using R STUDIO?


I’ll generate one data. Let’s say this is a math and english score for 8 students from different countries.

name=c("Jack","Kate","John","Jane","David","Min","Hyuk","Jisoo")
math=c(100,85,95,75,80,90,90,85)
eng=c(50,90,90,88,95,85,87,88)
country=c("USA","Spain","France","Germany","Netherlands", rep("Korea",3))
gender=c(rep(c("Male","Female"),times=4))
enroll=c(rep(c("Yes","No"),each=4))
grade=data.frame(name,math,eng,country,gender,enroll)
grade

I would like to adjust the scores by giving more weight to math. Since math was particularly difficult, I will increase the weight given to math.

grade$final= (grade$math*1.5 + grade$eng)/2
grade

Leave a Reply

If you include a website address in the comment section, I cannot see your comment as it will be automatically deleted and will not be posted. Please refrain from including website addresses.