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)
print(grade) name math eng country gender enroll 1 Jack 100 50 USA Male Yes 2 Kate 85 90 Spain Female Yes 3 John 95 90 France Male Yes 4 Jane 75 88 Germany Female Yes 5 David 80 95 Netherlands Male No 6 Min 90 85 Korea Female No 7 Hyuk 90 87 Korea Male No 8 Jisoo 85 88 Korea Female No
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
print(grade) name math eng country gender enroll final 1 Jack 100 50 USA Male Yes 100.00 2 Kate 85 90 Spain Female Yes 108.75 3 John 95 90 France Male Yes 116.25 4 Jane 75 88 Germany Female Yes 100.25 5 David 80 95 Netherlands Male No 107.50 6 Min 90 85 Korea Female No 110.00 7 Hyuk 90 87 Korea Male No 111.00 8 Jisoo 85 88 Korea Female No 107.75

We aim to develop open-source code for agronomy ([email protected])
© 2022 – 2025 https://agronomy4future.com – All Rights Reserved.
Last Updated: 11/24/2020