#piechart
x <- c(17.02, 42.99, 39.95)
labs <- c("Agus Silvy", "Ahok Djarot", "Anies Sandi")
piepercent <- round(100*x/sum(x), 1)
colors <- c("blue", "red", "green")
pie(x, 
    labels = piepercent, 
    main = "Perolehan Suara Pilkada DKI Putaran Pertama",
    col = colors(length(x))) 
legend("topright", labs, cex = 0.8, fill = colors(length(x)))

#Barchart
x <- c(17.02, 42.99, 39.95)
colors <- c("blue", "red", "green")
barplot(x,
        main = "Perolehan Suara Pilkada DKI",
        xlab = "Pasangan Calon",
        ylab = "Vote",
        names.arg = c("Agus Silvy", "Ahok Djarot", "Anies Sandi"),
        col = colors(length(x)),
        horiz = FALSE)