0
0
R Programmingprogramming~15 mins

Numeric and character vectors in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Numeric and character vectors
📖 Scenario: You are organizing a small party and want to keep track of the number of guests and their favorite drinks.
🎯 Goal: Create numeric and character vectors in R to store the number of guests and their favorite drinks, then display the information.
📋 What You'll Learn
Create a numeric vector called guest_counts with the exact values 5, 3, 7
Create a character vector called favorite_drinks with the exact values "Tea", "Coffee", "Juice"
Create a variable called total_guests that sums all values in guest_counts
Print the total_guests value
Print the favorite_drinks vector
💡 Why This Matters
🌍 Real World
Keeping track of guest counts and preferences helps in planning events and ordering the right amount of food and drinks.
💼 Career
Data analysts and event planners often work with numeric and character data to summarize and report information clearly.
Progress0 / 4 steps
1
Create the numeric vector
Create a numeric vector called guest_counts with the exact values 5, 3, 7.
R Programming
Need a hint?

Use the c() function to combine numbers into a vector.

2
Create the character vector
Create a character vector called favorite_drinks with the exact values "Tea", "Coffee", "Juice".
R Programming
Need a hint?

Use the c() function with quotes around each drink name.

3
Calculate total guests
Create a variable called total_guests that sums all values in the guest_counts vector.
R Programming
Need a hint?

Use the sum() function to add all numbers in the vector.

4
Print the results
Print the value of total_guests and then print the favorite_drinks vector.
R Programming
Need a hint?

Use print() to show the values on the screen.