Why vectors are the fundamental data structure
📖 Scenario: Imagine you are organizing a list of your favorite fruits. You want to store them in a simple way so you can easily add, remove, or check your fruits. In R, vectors are the best way to do this because they hold elements of the same type in a single container.
🎯 Goal: You will create a vector of fruits, add a new fruit, check the length of the vector, and print the final list. This will show why vectors are the fundamental data structure in R.
📋 What You'll Learn
Create a vector called
fruits with the exact values "apple", "banana", and "cherry"Create a variable called
new_fruit and set it to "orange"Add
new_fruit to the fruits vector using the c() functionPrint the length of the
fruits vector using the length() functionPrint the
fruits vector to show all fruits💡 Why This Matters
🌍 Real World
Vectors are used in data analysis, statistics, and many R programs to store lists of values like measurements, names, or categories.
💼 Career
Understanding vectors is essential for data scientists, statisticians, and anyone working with R because almost all data starts as vectors.
Progress0 / 4 steps