BU2010 Task R Vectors

Introduction

Overview

This week you get to work again with R. You will create a vector.

Editing

You can create documents and edit them directly in GitHub's web interface. This is a very convenient way of creating and editing the files.

In most cases, the preferred way of working is to create and edit the files on your own machine in RStudio. To get the files to your own computer use GitHub Desktop. How to use GitHub Desktop was explained in a previous class.

Advice

Once you are done be sure to commit your changes again (to save them to the repository) and to push them to GitHub (so that I can see the work you have done).

It's best if you Commit early, commit often - that way you can go back if you have made a mistake and I can see all the work you have done. It doesn't matter if your early commits contain mistakes.

Task Explanation

Below is today's task. We will be working with R.

For this task, you need to provide the answers in the vectors.R file you will find in this repository, not in the Markdown file you are currently reading.

Your Task

Your tasks can be found in the R script file vectors.R that is part of this repository. You have to work on these tasks by yourself. Do not work with others.

Please work on these tasks in RStudio - not on the GitHub website. If you work in RStudio you can make sure your code works as it should. If you don't work in RStudio, but edit the file on the GitHub web interface you will have to copy and paste the code into R for testing - an unnecessary step that can introduce mistakes.

Pay attention to the autocomplete options RStudio is offering you and use them to explore how R commands work. Also, remember how useful the cursor keys and the Tab key can be. Pressing F1 will bring up the documentation for the selected command in the Help tab.

Please don't forget to push your commit.

You will find the following question in vectors.R. In that file please write your code below the comment with the question. I have started some of the lines with the code for the answers for you.

Question 1

Set up a vector named modules consisting of the module codes of all modules you study this year.

Question 2

Find out the cost of the main textbook from each of these modules.

If you are not sure which book to take just take the first book from the module's reading list. If you are not sure about the correct price just use the price you can find on the website of an online retailer or on the website of the publisher.

Set up a vector named book_costs consisting of the book costs. Use the same order as you did in the modules vector.

Question 3

Set modules as the names of book_costs.

Question 4

What do you need to type into R or R Studio to display the object you created, i.e. to show the book costs and the module codes?