Error : length of ‘dimnames’ [2] not equal to array extent

You need to supply one more column name. Your data has eight columns, as can be seen, e.g., with

> length(fcm)
[1] 8

or

> ncol(data1)
[1] 8

or by displaying the matrix:

> data1
#    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#fcm 14.0 14.1 13.0   14  2.0 14.7 13.8 14.0
#gk  12.1 12.5 12.2   12  0.0 11.5 12.0 11.4
#gg  14.0 14.1 13.0    3 12.8 12.0 12.2 12.0

while

> length( c(6, 7, 8, 9, 10, 11, 12))
[1] 7

You could try with

colnames(data1) <- c(6:13)

With your data, this would be:

fcm <-c(14.0,14.1,13.0,14,2,14.7,13.8,14.0)
gk  <-c(12.1,12.5,12.2,12,0,11.5,12.0,11.4)
gg  <-c(14.0,14.1,13,3,12.8,12.0,12.2,12.0)
data1 <- rbind(fcm,gk,gg)
colnames(data1) <- c(6:13)

which gives:

> data1
       6    7    8  9   10   11   12   13
fcm 14.0 14.1 13.0 14  2.0 14.7 13.8 14.0
gk  12.1 12.5 12.2 12  0.0 11.5 12.0 11.4
gg  14.0 14.1 13.0  3 12.8 12.0 12.2 12.0

without any error message.

Leave a Comment

tech