R绘图-极坐标、条形图

# Library
library(fmsb)

# Create data: note in High school for Jonathan:
data <- as.data.frame(matrix( sample( 2:20 , 10 , replace=T) , ncol=10))
colnames(data) <- c(" 数学" , "english" , "biology" , "music" , "R-coding", "data-viz" , "french" , "physic", "statistic", "sport" )

# To use the fmsb package, I have to add 2 lines to the dataframe: the max and min of each topic to show on the plot!
data <- rbind(rep(20,10) , rep(0,10) , data)

# Check your data, it has to look like this!
head(data)

# The default radar chart
radarchart(data)

library("vcd")
data(Arthritis, package="vcd")
table(Arthritis$Improved)

library(ggplot2)
ggplot(Arthritis, aes(x=Improved)) + geom_bar()
labs(title="Simple Bar chart",
     x="Improvement", y="Frequency")
ggplot(Arthritis, aes(x=Improved)) + geom_bar()
labs(title="Horizontal Bar chart",
     x="Improvement",
     y="Frequency")
coord_flip() 

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注