how to create dictionary in R

# Step 1: Create an empty list
my_dict <- list()

# Step 2: Add key-value pairs to the list
my_dict[["name"]] <- "John"
my_dict[["age"]] <- 30
my_dict[["city"]] <- "New York"

# Step 3: Access values using keys
name_value <- my_dict[["name"]]
age_value <- my_dict[["age"]]
city_value <- my_dict[["city"]]

# Step 4: Print the dictionary
print(my_dict)

# Step 5: Update a value
my_dict[["age"]] <- 31

# Step 6: Print the updated dictionary
print(my_dict)

# Step 7: Remove a key-value pair
my_dict[["city"]] <- NULL

# Step 8: Print the dictionary after removing a key-value pair
print(my_dict)