After today’s lab you will be able to:
Describe the difference between R and Rstudio and distinguish between the console and a script file
Create an Rmarkdown document and describe and example of where you would use an Rmarkdown document.
Describe functions in R and identify the components of a function
Describe the difference between [] and () (e.g., when and how to use these different brackets/parentheses)
Today we will create an Rmarkdown document to answer the following questions. You have learned that there are some datasets that are built into R. Today we we will play with the iris
dataset. We will get more practice in familiarising ourselves with a new dataset and will practice subsetting as we have done We are also going to get some practice working
iris
What are the column names and data types of the different columns in iris?
How many rows and columns does iris have?
Create a single vector (a new object) called ‘width’ that is the Sepal.Width column of iris.
What is the 100th value in your ‘width’ vector?
What is the last value in your ‘width’ vector? Can you write code that returns this value even if you don’t know how long ‘width’ is?
Select rows 10 to 20, with all columns in the iris dataset.
Select rows 10 to 20 with only the Species, Petal.Width and Petal.Length. Can you do this two different ways?
Select rows 1 to 10, 20, and 100 in the iris dataset.
Select the first value in the Sepal.Length column of the iris dataset. Bonus - can you do this three different ways?