Un For que imprima error si no son números enteros

Hola, necesito que me permita hacer un For y que me imprima solo cuando son números enteros positivos de 6 dígitos. Tengo esto:

PUC = rbind("aaaaaa", 2, 333333, 777.72, 567899.5, 111111, -23455, -123456 , - 123456.6, 8889.5)

PUC = as.numeric(PUC)
for(i in 1:length(PUC)) {PUC[i] = ifelse(nchar(PUC[i]) == 6 & PUC[i] >= 0, PUC[i], paste("(",PUC[i],")","-","ERROR, debe ser un número entero positivo de 6"))}
for(i in 1:length(PUC)) {PUC[i] = ifelse(is.na(PUC[i]), paste("(",PUC[i],")","-","ERROR, debe ser un número"),PUC[i])}
PUC

This topic was automatically closed 42 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.