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

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:

主站蜘蛛池模板: 肇源县| 礼泉县| 天津市| 曲周县| 固原市| 康马县| 如东县| 潞西市| 如东县| 武宁县| 桐梓县| 连南| 韩城市| 宽城| 镇平县| 荥经县| 溧水县| 田林县| 江北区| 富蕴县| 射洪县| 内黄县| 潍坊市| 越西县| 旺苍县| 兰西县| 宣化县| 林芝县| 济源市| 平武县| 扎鲁特旗| 铜川市| 景德镇市| 沁源县| 拜泉县| 嘉义市| 永顺县| 乌拉特前旗| 兰坪| 南丰县| 瑞丽市|