2.4 Executing Code

REVIEW To send R commands to the R Console we can use the appropriate toolbar buttons. One line or a highlighted region can be sent using the Run button. Having opened a new R script file we can enter the commands below. The four commands make up a program which begins with an install.packages() to ensure we have installed two requisite software packages for R. The second and third commands use library() to load those packages into the current R session. The fourth command produces a plot of the weatherAUS dataset. This dataset contains daily observations of weather related variables across some 50 weather stations in Australia over multiple years.

install.packages(c("ggplot2", "rattle"))
library(ggplot2)
library(rattle)
qplot(data=weatherAUS, x=MinTemp, y=MaxTemp)

qplot() allows us to quickly code a plot. Using the weatherAUS dataset we plot the minimum daily temperature (MinTemp) on the x-axis against the maximum daily temperature (MaxTemp) on the y-axis. The resulting plot is a scatter plot as we see the plot in the lower right pane.



Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0