Anche se la domanda sembra essere duplicata, la sto postando in quanto nessuna di esse ha fornito una soluzione e pertinente al mio problema.REAL() può essere applicato solo a un 'numerico', non a un 'intero'
dtrain<-xgb.DMatrix(data=data.matrix(train),label=data[t,c(31)])
Errore nei xgb.DMatrix (data = data.matrix (treno), etichetta = dati [t, c (31)]): REAL() può essere applicato solo a un 'numerico', non un 'intero'
> class(data[t,c(31)])
[1] "integer"
> str(train)
'
data.frame': 1965 obs. of 30 variables:
$ having_IP_Address : int 2 2 2 2 2 2 2 2 2 2 ...
$ URL_Length : int 3 3 3 3 3 3 3 3 3 3 ...
$ Shortining_Service : int 1 1 1 1 1 1 1 1 1 1 ...
$ having_At_Symbol : int 1 1 1 1 1 1 1 1 1 1 ...
$ double_slash_redirecting : int 2 2 2 2 2 2 2 2 2 2 ...
$ Prefix_Suffix : int 2 2 1 2 3 2 1 1 3 1 ...
$ having_Sub_Domain : int 1 2 1 1 1 3 1 2 1 1 ...
$ SSLfinal_State : int 2 2 2 1 2 2 1 2 2 2 ...
$ Domain_registeration_length: int 3 1 3 2 2 1 2 3 2 1 ...
$ Favicon : int 1 2 1 1 1 1 1 1 2 1 ...
$ port : int 1 2 1 1 1 1 1 1 2 1 ...
$ HTTPS_token : int 2 2 2 2 2 2 2 2 2 2 ...
$ Request_URL : int 1 1 1 2 2 1 2 1 2 1 ...
$ URL_of_Anchor : int 2 2 2 2 2 3 1 2 3 1 ...
$ Links_in_tags : int 3 2 3 3 1 3 2 1 3 2 ...
$ SFH : int 1 1 1 1 1 1 1 1 1 1 ...
$ Submitting_to_email : int 2 1 2 2 2 2 2 1 1 2 ...
$ Abnormal_URL : int 2 2 2 2 2 2 2 2 2 2 ...
$ Redirect : int 1 1 1 1 1 1 1 1 1 1 ...
$ on_mouseover : int 1 2 1 1 1 1 1 1 1 1 ...
$ RightClick : int 1 1 1 1 1 1 1 1 1 1 ...
$ popUpWidnow : int 1 2 1 1 1 1 1 1 2 1 ...
$ Iframe : int 1 2 1 1 1 1 1 1 2 1 ...
$ age_of_domain : int 3 1 1 1 3 3 1 1 1 1 ...
$ DNSRecord : int 2 1 1 2 1 2 1 2 2 1 ...
$ web_traffic : int 3 3 2 3 3 3 1 3 2 2 ...
$ Page_Rank : int 2 3 1 1 1 1 1 1 1 1 ...
$ Google_Index : int 1 1 1 1 1 1 1 1 1 1 ...
$ Links_pointing_to_page : int 2 1 3 2 1 2 1 3 2 2 ...
$ Statistical_report : int 2 1 2 2 2 2 2 2 2 2 ...
che tutto quello che ho capito dalla ricerca questo errore è reale() non può essere applicato alle liste. Sono senza tracce cos'è questo REAL(). Grazie in anticipo !!
Hai provato la conversione dei dati numerici come l'errore suggerisce 'treno [] <- lapply (train, as.numeric) ', e quindi usare' xgb.DMatrix (data = data.matrix (train)) ' – user20650