# 7-2 Editing lists

# Create a starter list

z<-list(a="abc", b=42)

# Display list

z

# Add a new element with a new tag

z$c<-"marshmallow"

# Display list

z

# Add a new element using a vector index

z[[4]]<-TRUE

# Display list
# Note that the 4th entry only has an index number, not a tag

z

# Adding a group of elements of the same data type
# Note that this uses single, not double, square brackets

z[6:8]<-c(TRUE, FALSE, FALSE)

# Display list
# Note that the added entries have index numbers

z

# Delete a list element

z[[3]]<-NULL

# Display list
# Note that the index numbers have changed

z

# Calculate the list length

length(z)

# Adding elements by concatenation

# Rebuild the list from the 7-1-CreatingLists

j<-list(name="Jack", age=22, overseas=F)

# Create a new list from this one and some extra terms

c(j,list(city="Swansea",startyear=2018))