官术网_书友最值得收藏!

Plotting with qplot and R

Suppose that we want to visualize some of the variables in the built-in datasets. A dataset can contain different kinds of variables, as discussed previously. Here, the climate data includes numerical data, such as the temperature, and categorical data, such as hot or cold. In order to visualize and correlate different kinds of data, we need to understand the nomenclature of the dataset. We'll load a data file and understand the structure of the dataset and its variables by using the qplot and R base package. Let's begin by executing the following steps:

  1. Plot the temperature variable from the airquality dataset, with hist(airquality$Temp) .

hist is part of the built-in R graphics package.

  Take a look at the following output screenshot:

  1. Use qplot (which is part of the ggplot2 package) to plot a graph, using the same variables.
  1. Type the qplot(airquality$Temp) command to obtain the output, as shown in the following screenshot:

主站蜘蛛池模板: 金湖县| 武冈市| 长春市| 临泽县| 兴国县| 五原县| 莱州市| 怀化市| 九龙县| 葵青区| 南宫市| 新民市| 封丘县| 枝江市| 贵州省| 香格里拉县| 上林县| 德江县| 疏附县| 洮南市| 光泽县| 乌恰县| 京山县| 铁岭市| 朝阳区| 隆安县| 库尔勒市| 永平县| 东台市| 宜川县| 德清县| 皮山县| 中牟县| 石泉县| 永和县| 剑河县| 武乡县| 孝昌县| 双流县| 武强县| 安达市|