# Сhange directory
setwd("D:\\Dropbox\\!Сайт\\7_Библиотека\\Яу\\Столбчатая диаграмма")

# Load data
hotdogs <- read.csv("data/hot-dog-contest-winners.csv", sep=",", header=TRUE)

# hotdogs <- read.csv("http://datasets.flowingdata.com/hot-dog-contest-winners.csv", sep=",", header=TRUE)

# Default barchart
barplot(hotdogs$Dogs.eaten)

# Year labels
barplot(hotdogs$Dogs.eaten, names.arg=hotdogs$Year)

# Axis labels
barplot(hotdogs$Dogs.eaten, names.arg=hotdogs$Year, xlab="Годы", ylab="Число съеденных хот-догов")

# Fill color and border
barplot(hotdogs$Dogs.eaten, names.arg=hotdogs$Year, col="red", border=NA, xlab="Годы", ylab="Число съеденных хот-догов")

# Highlight record years with color
fill_colors <- c()
for ( i in 1:length(hotdogs$New.record) ) {
	if (hotdogs$New.record[i] == 1) {
		fill_colors <- c(fill_colors, "#821122")
	} else {
		fill_colors <- c(fill_colors, "#cccccc")
	}
}
barplot(hotdogs$Dogs.eaten, names.arg=hotdogs$Year, col=fill_colors, border=NA, xlab="Годы", ylab="Число съеденных хот-догов")
