Chapter 3: Finding your way around

This tutorial is different because it has no explicit challenge at the end of it. It’s optional because what it’s going to help you do is expose you to some commands which are will help you find your way around to simplify the use of R.

Again the same instructions. Type in these commands and you’ll get a feel of what each does.

#scroll the previous commands using the arrow keys
#the above in case you haven’t figured out that R is annoyingly case sensitive
#Installing packagesgoto packages and data (in the mac OSX) and select the package ggplot2 to be installed. Alternatively it ca be installed directly from the command line. The library function loads it into the space.
#R has some inbuilt data sets – let’s explore them
# A tiny glimpse of ggplot2
ggplot(data = diamonds, mapping = aes(x = price)) + layer(geom = “bar”, stat = “bin”, mapping = aes(y = ..count..))

#Demo of graphics in R – some fascinating examples of what you can create


Once done – Take the above code –copy paste it into an editor and write a comment before the start of each line explaining what it does. Use help() if required.

Concepts introduced: Today we implicitly introduced packages in R – think of packages as pre built modules which are written to help us with certain capabilities. ggplot2 is a powerful graphics package which we will look into depth much later.

Leave a Reply

Your email address will not be published.