Home > Blockchain >  R: how to solve length of 'dimnames' [1] not equal to array extent and data length [92] is
R: how to solve length of 'dimnames' [1] not equal to array extent and data length [92] is

Time:11-01

I am trying to create a matrix, but it displays the following errors:

any suggestion? Datos object length is 92

datos<-c(Mondays,Tuesdays,Wednesdays,Thursdays)
dias<-c("Monday","Tuesday","Wednesday","Thursday")
horas<-0:23
days<-matrix(datos, nrow=24,ncol=4,dimnames=list(dias, horas))
days
length of 'dimnames' [1] not equal to array extent

In addition: Warning message:
In matrix(datos, nrow = 24, ncol = 4, dimnames = list(dias, horas)) :
  data length [92] is not a sub-multiple or multiple of the number of rows [24]

I am trying to create a matrix, but it displays these erros. how to understand this problem in order to solve it

CodePudding user response:

If the length of 'datos' is 92, we can append NAs at the end so that it is a multiple of 24 i.e. 96

matrix(`length<-`(datos, 24 *4), nrow=24, ncol = 4, dimnames = list(horas, dias))
  •  Tags:  
  • r
  • Related