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

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:

主站蜘蛛池模板: 沂源县| 安西县| 临海市| 阿拉善左旗| 开化县| 八宿县| 汉川市| 山东省| 宁海县| 雅江县| 明水县| 平利县| 双城市| 德保县| 波密县| 榆林市| 玉林市| 黄陵县| 辽宁省| 社旗县| 阿图什市| 桃江县| 托克逊县| 建始县| 全州县| 九寨沟县| 阿尔山市| 辽阳市| 大悟县| 武穴市| 苍溪县| 南漳县| 康保县| 名山县| 城固县| 屏东市| 乌什县| 广昌县| 商水县| 铁力市| 宁远县|