It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Introduction to lists
5. Creating a list
Accessing list elements
Unnamed lists
Working with lists
Summary

Instruction

Great! Now that we know how to display a list, let's learn how to create one!

Lists in R are created with the list() function. Let's create a list containing information for a candidate named Luke Smith:

candidate_2 <- list(name = "Luke Smith", 
                    country = "Israel", 
                    age = 30, 
                    skills = c("Oracle", "DB2", "PostgreSQL"))

The arguments of the function are the members of the list you wish to create. Each member name is followed by the = sign and the value you'd like to assign to that member. For example, the skills member is a vector, so we used the c() function to give it three character values: "Oracle", "DB2", and "PostgreSQL".

Exercise

Create a list containing the following elements and values:

name value
job_position "data scientist"
years_of_experience 10
skills c("R", "Python", "Spark", "Cloudera", "Hive", "Impala")

Assign this list to a variable named data_scientist_role.