1. Frequency table
2. BarPlot
3. Pie chart
The above examples are contained in the paragraph 2.1 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.
colors = c("Κόκκινο", "Μπλε", "Πράσινο", "Κόκκινο", "Μπλε", "Κόκκινο")
my.table = as.data.frame(table(colors))
my.table$Perc = round(my.table$Freq / sum(my.table$Freq) * 100, 1)
my.table
2. BarPlot
colors = c("Κόκκινο", "Μπλε", "Πράσινο", "Κόκκινο", "Μπλε", "Κόκκινο")
barplot(table(colors), main="Αγαπημένο χρώμα", xlab="Χρώμα", axes = F, col = c("firebrick1" , "dodgerblue3", "chartreuse3"))
axis(2, c(0,1,2,3)
3. Pie chart
cols = c("firebrick1" , "dodgerblue3", "chartreuse3")
pielabels= paste(my.table$Perc, "%", sep="")
pie(table(colors), radius = 1, main="Αγαπημένο χρώμα", col= cols, labels=pielabels, cex=0.8)
legend("topright", c("Κόκκινο", "Μπλε", "Πράσινο"), cex=0.8, fill=cols)
The above examples are contained in the paragraph 2.1 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.
Comments
Post a Comment