2.21 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.



If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, 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