r语言 图形一览_R语言之图形概览

本文将讨论用R语言自带的基本绘图系统和ggplot2包来讨论基本图形的绘制。

一、条形图(bar chart):

我在学习这部分时会遇到这样的困惑,觉得条形图(bar chart)和直方图(histogram)差不多,两者都是用来统计频数的,histogram还可以用来统计频率。简单来说,条形图注重分类,而直方图更多用于绘制一系列有意义的连续型变量,具体例子见下文。Both charts display a summary value of a continuous variable that has been split into groups.

In bar charts, the groups are typically categorical variables.

In histograms the groups are typically intervals of another continuous variable.

# of people enrolled in each department of a college would suit a bar chart

# of people in each income quintile in your city would suit a histogram

One implication of this difference is that a natural order exists on the grouping axis of a histogram, but not a bar chart. In other words, it usually makes sense to sort a bar chart by value of the bar but a histogram should almost always remain sorted by the order of the groups. Using the examples above:

It would make sense to order the college departments from highest to lowest enrollment.

It wouldn't make as much sense to order the income quintiles by most to least people, you would end up with a counter-intuitive graph.

Bar charts usually have a space between the bars, histograms usually don't - reflecting the subtle differences in the relationships between adjacent groups.

—— Excerps from QUORA

见代码,这里使用vcd包里的Arthritis数据框作例子,先来看一下它里面有些啥:

> library(vcd)

载入需要的程辑包:grid

> head(Arthritis)

ID Treatment Sex Age Improved

1 57 Treated Male 27 Some

2 46 Treated Male 29 None

3 77 Treated Male 30 None

4 17

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值