r – Error : length of dimnames [2] not equal to array extent
r – 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.
r – Error : length of dimnames [2] not equal to array extent
Related posts on array :
- c++ – Remove duplicates from an unsorted array
- Declaring an array in pseudocode
- Difference between ArrayIterator, ArrayObject and Array in PHP
- php – array_walk_recursive with array?
- Return Largest Numbers in Arrays in javascript
- set – No Java implementations for arrayset
- java – Finding the second smallest integer in array
- Correct way to synchronize ArrayList in java