rowname() function error

rowname(filename) <- filename[,1] shows

Error in .rowNamesDF<-(x, value = value) : invalid 'row.names' length

Please help me to solve this error.

the function is called rownames() not rowname() (if we are talking about base R)
the row.names length will be invalid if the number of rows of the object on the left dont match the character vector on the right's number of entries.
So how many rows do you have ?


how long is your vector ?


final thought is that row.names are a traditional/old feature of R, modern toolsets like tidyverse recommend avoiding them altogether, and I too find there are very limited uses for row names, a data.frame can simple have a traditional column used for the purpose of labelling a row. So perhaps don't try to use "row names" anywahy ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.