'names' attribute must be the same length as the vector

r

Solution

In the spirit of @Chris W, just try to replicate the exact error you are getting. An example would have helped but maybe you're doing:

  x <- c(1,2)
  y <- c("a","b","c")
  names(x) <- y

Error in names(x) <- y : 
  'names' attribute [3] must be the same length as the vector [2]

I suspect you're trying to give names to a vector (`x`) that is shorter than your vector of names (`y`).

Problem

Stuck on an error in R. ``` Error in names(x) <- value : 'names' attribute must be the same length as the vector ``` What does this error mean?

Original source

Related problems