No=seq(1,15,1)
Nama=c("George Wadded Snedecor","Johann Carl Friedrich
Gauss","William Sealy Gosset","Andrey
Kolmogorov","Hubert Lilliefors","John
Tukey","Ronald Aylmer Fisher","Frank Yates","Maurice
Stevenson Bartlett","George Edward Pelham Box","Francis
Galton","Karl Pearson","Charles Edward
Spearman","James Durbin","Geoffrey Watson")
IPA=c("A","A","A","B","C","C","C","A","A","A","B","B","A","B","A")
IPS=c("C","A","B","C","B","B","A","A","C","B","B","B","C","C","C")
MATE=c("C","A","B","A","A","A","A","A","B","C","B","B","A","C","A")
BIND=c("B","C","A","A","C","C","A","C","C","B","B","A","B","A","C")
BING=c("B","A","A","C","C","C","B","C","C","A","C","B","A","C","C")
BSIPA=3
BSIPS=3
BSMATE=3
BSIND=2
BSING=2
jumlahsks=BSIPA+BSIPS+BSMATE+BSIND+BSING
fungsi
nilai=function(IPA,IPS,MATE,BIND,BING,BSIPA,BSIPS,BSMATE,BSIND,BSBING,jumlahsks)
{
n=length(IPA)
nipa=c(rep(0,n))
for (i in 1:n)
{
if (IPA[i] ==
"A")
{
nipa[i] <- 4
}
else
{
if (IPA[i] == "B")
{
nipa[i] <- 3
} else
{
if (IPA[i] == "C")
{
nipa[i] <- 2
} else
{
if (IPA[i] == "D")
{
nipa[i] <- 1
} else
{
nipa[i] <- 0
}
}
}
}
}
n=length(IPS)
nips=c(rep(0,n))
for (i in 1:n)
{
if (IPS[i] == "A")
{
nips[i] <- 4
} else
{
if (IPS[i] == "B")
{
nips[i] <- 3
} else
{
if (IPS[i] == "C")
{
nips[i] <- 2
} else
{
if (IPS[i] == "D")
{
nips[i] <- 1
} else
{
nips[i] <- 0
}
}
}
}
}
n=length(MATE)
nmate=c(rep(0,n))
for (i in 1:n)
{
if (MATE[i] == "A")
{
nmate[i] <- 4
} else
{
if (MATE[i] == "B")
{
nmate[i] <- 3
} else
{
if (MATE[i] == "C")
{
nmate[i] <- 2
} else
{
if (MATE[i] == "D")
{
nmate[i] <- 1
} else
{
nmate[i] <- 0
}
}
}
}
}
n=length(BIND)
nindo=c(rep(0,n))
for (i in 1:n)
{
if (BIND[i] == "A")
{
nindo[i] <- 4
} else
{
if (BIND[i] == "B")
{
nindo[i] <- 3
} else
{
if (BIND[i] == "C")
{
nindo[i] <- 2
} else
{
if (BIND[i] == "D")
{
nindo[i] <- 1
} else
{
nindo[i] <- 0
}
}
}
}
}
n=length(BING)
ning=c(rep(0,n))
for (i in 1:n)
{
if (BING[i] == "A")
{
ning[i] <- 4
} else
{
if (BING[i] == "B")
{
ning[i] <- 3
} else
{
if (BING[i] == "C")
{
ning[i] <- 2
} else
{
if (BING[i] == "D")
{
ning[i] <- 1
} else
{
ning[i] <- 0
}
}
}
}
}
IPK=c(rep(0,n))
for (i in 1:n)
{
IPK[i]=(sum((nipa[i]*BSIPA)+(nips[i]*BSIPS)+(nmate[i]*BSMATE)+(nindo[i]*BSIND)+(ning[i]*BSING))/jumlahsks)
}
n=length(IPK)
pk=c(rep(0,n))
for (i in 1:n)
{
if (IPK[i] >=
3.51 && IPK[i] <= 4.00)
{
pk[i] <- "Cum Laude"
}
else
{
if (IPK[i] >= 2.76 && IPK[i] <= 3.50)
{
pk[i] <- "Sangat Memuaskan"
} else
{
if (IPK[i] >= 2.00 && IPK[i] <= 2.75)
{
pk[i] <- "Memuaskan"
}
}
}
}
output=data.frame(No=No,NamaLengkap=Nama,IPA=IPA,IPS=IPS,Matematika=MATE,BahasaIndonesia=BIND,Bahasainggris=BING,IPK=IPK,PredikatKelulusan=pk)
return(output)
}
Makasih gan :D bisa dipraktekin nih artikel Berbagi Bersama: cara membuat fungsi di R
BalasHapusKujungi balik + Komentar yuk gan :D Cari Dulu | Tutorial Bermamfaat Membahas Komputer & Blogging