# Exercice 7-3 Creating and editing lists

# Create a list animals

animals<-list(PetName="Gracie",   # Newlines make things readable
              AnimalType="Dog",
              Breed="Greyhound",
              Age=11)

# Display list

animals

# Add the weight element

animals$Weight<-27.5

# Display list

animals

# Add a Boolean element for Alive

animals$Alive=TRUE

# Display list

animals

# Remove the breed element

animals$Breed<-NULL   # animals[[3]]<-NULL also works

# Display list

animals

# Change age to 14

animals$Age<-14    # animals[[3]]<-14 also works

# Display list

# Add elements for Sex and Family Name
# Lots of ways of doing this!

animals<-c(animals,list(Sex="Female"),list(FamilyName="Nusbacher"))

# Display list

animals