为什么表函数会找到一个被删除的变量?
Dog <- c("Rover", "Spot")
Cat <- c("Scratch", "Fluffy")
Pets <- data.frame(Dog, Cat) #create a data frame with two variables
names(Pets)
# [1] "Dog" "Cat"
#rename Dog to a longer name
names(Pets)[names(Pets)=="Dog"] <- "Dog_as_very_long_name"
Pets$Dog <- NULL # delete Dog
names(Pets)
#[1] "Dog_as_very_long_name" "Cat" #the variable dog is not in the data set anymore
table(Pets$Dog) #Why does the table function on a variable that was deleted
# Rover Spot
# 1 1