R programming | R graphic ggplot2 Bar charts
Автор: rdatacode
Загружено: 2023-12-07
Просмотров: 59
simple vertical bar chart
ggplot(grade, aes(x=Gender)) + geom_bar() +
labs(title="Simple Bar chart",
x="Gender",
y="Frequency")
#Simple horizontal bar chart
ggplot(grade, aes(x=Gender)) + geom_bar() +
labs(title="Horizontal Bar chart",
x=“Gender",
y="Frequency") +
coord_flip()
stacked, grouped, or filled bar charts can show the relationship between
two categorical variables
stacked bar chart: each segment represents the frequency or proportion of
Country within a given Gender
ggplot(grade, aes(x=Gender, fill=Country)) +
geom_bar(position = "stack") +
labs(title="Stacked Bar chart",
x="Gender",
y="Country")
grouped bar chart: segments of Country sit side by side within each Gender
ggplot(grade, aes(x=Gender, fill=Country)) +
geom_bar(position = "dodge") +
labs(title="Grouped Bar chart",
x="Gender",
y="Country")
filled bar chart: a stacked bar chart rescaled so that the height of each bar is 1
and the segment heights represent proportions
ggplot(grade, aes(x=Gender, fill=Country)) +
geom_bar(position = "fill") +
labs(title="Filled Bar chart",
x="Gender",
y="Country")
#rprogramming
#rstudio
#ggplot
#barchart
#stack
#rdatacode
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: