The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Rbind does not work

Rbind does not work

Super Learner
0
Votes
2
Answer

Hi,
we had the following exercise and it worked well till last rbind. I have the following warning. Can you help to figure it out? Thank you.
Error in match.names(clabs, names(xi)) :
names do not match previous names
 
name <- c(“Flipper”, “Bromley”, “Nox”, “Orion”, “Dagger”, “Zizi”, “Carrie”)
mo <- c(53, 19, 34, 41, 84, 140, 109)
size <- c(“medium”, “small”, “medium”, “large”, “small”, “extra small”, “large”)
weight <- c(21, 8, 4, 6, 7, 2, 36)
breed <- c(“dog”, “dog”, “cat”, “cat”, “dog”, “cat”, “dog”)
pets <- data.frame(mo, size, weight, breed)
names(pets) <- c(“Months old”, “Size”, “Weight”, “Breed”)
rownames(pets) <- name
pets
vaccinated <- c(“Yes”, “Yes”, “No”, “Yes”, “No”, “No”, “Yes”)
petsv <- cbind(pets, “Vaccinated” = vaccinated)
petsv
milo <- data.frame(row.names = “Milo”, Months.old = 67, Size = “small”, Weight = 7, Breed = “dog”, Vaccinated = “Yes”)
petsvm <- rbind(petsv, milo)
petsvm

2 Answers

0
Votes

As the error message indicated, the column name that you want to rbind (Months.old) is different from the main column name (Months old). 

Super Learner
0
Votes

Hi Joonseok,
when defining name, the space is allowed like “Months old” 
names(pets) <- c(“Months old”, “Size”, “Weight”, “Breed”).
 
when define a row with name, the space is not allowed, like Months old
milo <- data.frame(row.names = “Milo”, Months old = 67, Size = “small”, Weight = 7, Breed = “dog”, Vaccinated = “Yes”). so
How can we keep the name with space if I want to add a row as in this example?