Tag Archives: bnlearn

13. R language: Error in match.names(clabs, names(xi)): The name is not relative to the original name

Problem description

Count_bind = rbind(count_left,count_right)
Error in match.names(clabs, names(xi)) : names are not relative to existing names

To explore the reason
This is a problem in the match.names function that occurs during rbind, for the simple reason that my first two objects to be rbind have different column names:


To solve the problem
Manually changing the column name can solve the problem:

colnames(count_left) <- c("AAA")

Use the above function to execute the two objects separately, and just change the column name.
Big mouth a
I’ve never really understood why data.frame cannot set the column name when declared but can set the row name. Below is the official usage, only for row row.

The data frame (… , row.names = NULL, check.rows = FALSE,
check.names = TRUE, fix.empty.names = TRUE,
stringsAsFactors = default.stringsAsFactors())

In this way, I often have to manually name the column names of the data box. Usually, the code I write is genetic data, so as to ensure the accuracy of the column names. However, it would be troublesome to write small codes for statistics
Welcome to communicate