Namings | Vectors

Course Content

# R Introduction: Part I

R Introduction: Part I

## Namings

Now that you're familiar with creating vectors, let's apply them to store and label valuable information, such as grades on a scale from 1 to 100. However, the grades alone may not be self-explanatory to someone else.

Suppose the grades are as follows:

 Subject Grade Math 80 Physics 75 English 95 Literature 100

While you know how to create a vector with grades, the next step is labeling those values with their corresponding subjects. This can be done by assigning a vector of names to `names(vector)`, where `vector` is your original vector that you wish to label. Here's how you can do that.

That presents the information more clearly.

Imagine you manage a local furniture store. You have a list of items and their respective prices as shown below:

 Item Price Sofa 340 Armchair 150 Dining table 115 Dining chair 45 Bookshelf 160

Your task is to store the prices in a vector named `prices` and label each price with the corresponding item.

1. Construct a vector of prices and store it in the variable `prices`.
2. Use the variable `items` to assign names to the elements in the `prices` vector.
3. Display the `prices` vector.

Everything was clear?

Section 2. Chapter 7

Course Content

# R Introduction: Part I

R Introduction: Part I

## Namings

Now that you're familiar with creating vectors, let's apply them to store and label valuable information, such as grades on a scale from 1 to 100. However, the grades alone may not be self-explanatory to someone else.

Suppose the grades are as follows:

 Subject Grade Math 80 Physics 75 English 95 Literature 100

While you know how to create a vector with grades, the next step is labeling those values with their corresponding subjects. This can be done by assigning a vector of names to `names(vector)`, where `vector` is your original vector that you wish to label. Here's how you can do that.

That presents the information more clearly.

Imagine you manage a local furniture store. You have a list of items and their respective prices as shown below:

 Item Price Sofa 340 Armchair 150 Dining table 115 Dining chair 45 Bookshelf 160

Your task is to store the prices in a vector named `prices` and label each price with the corresponding item.

1. Construct a vector of prices and store it in the variable `prices`.
2. Use the variable `items` to assign names to the elements in the `prices` vector.
3. Display the `prices` vector.

Everything was clear?

Section 2. Chapter 7