Forçar a geração do número das linhas em as.matrix() combinado com funções do pacote dplyr

Prezados Membros do r-br, Estou tentando criar um objeto X_train através de funções do pacote dplyr e a função as.matrix(), mas eu não consigo criar o número das linhas para esse objeto. Meu CMR é: |library(dplyr) RES_F<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/cnn_ds.csv",sep=",",h=T) RES_train<-RES_F%>% group_by(status) %>% sample_n(1280) X_train <- RES_train %>% select(-status) %>% as.matrix(nrow = length(RES_train[,2]), ncol = ncol(RES_train)-1, byrow = TRUE) str(X_train) # chr [1:2560, 1:5] "attack" "attack" "attack" "attack" "attack" "attack" "attack" "attack" "attack" "attack" "attack" ... # - attr(*, "dimnames")=List of 2 # ..$ : NULL # ..$ : chr [1:5] "status" "NDVI" "SIPI" "RGI" ...| Podemos ver que aparece NULL: |# ..$ : NULL # ..$ : chr [1:5] "status" "NDVI" "SIPI" "RGI" ...| , mas eu quero que meu output seja: |# ..$ : chr [1:2560] "1" "2" "3" "4" ... # ..$ : chr [1:5] "status" "NDVI" "SIPI" "RGI" ...| Por favor, alguma sugestão? Obrigado e abraços, Alexandre -- Alexandre dos Santos Geotechnologies and Spatial Statistics applied to Forest Entomology Instituto Federal de Mato Grosso (IFMT) - Campus Caceres Caixa Postal 244 (PO Box) Avenida dos Ramires, s/n - Vila Real Caceres - MT - CEP 78201-380 (ZIP code) Phone: (+55) 65 99686-6970 / (+55) 65 3221-2674 Lattes CV: http://lattes.cnpq.br/1360403201088680 OrcID: orcid.org/0000-0001-8232-6722 ResearchGate: www.researchgate.net/profile/Alexandre_Santos10 Publons: https://publons.com/researcher/3085587/alexandre-dos-santos/ --

rownames(X_train) <- seq(1,nrow(X_train)) ---------------------------------------------------------------- Daniel Tiezzi, MD, PhD Oncologia / Mastologia Professor Associado - Livre Docente Departamento de Ginecologia e Obstetrícia Setor de Mastologia e Oncologia Ginecológica Faculdade de Medicina de Ribeirão Preto - USP Tel.: 16 3602-2488 e-mail: dtiezzi@usp.br <mailto:dtiezzi@usp.br> https://github.com/dtiezzi <https://github.com/dtiezzi>
On 25 Nov 2020, at 16:03, ASANTOS por (R-br) <r-br@listas.c3sl.ufpr.br> wrote:
library(dplyr) RES_F<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/cnn_ds.csv" <https://raw.githubusercontent.com/Leprechault/trash/main/cnn_ds.csv>,sep=",",h=T) RES_train<-RES_F%>% group_by(status) %>% sample_n(1280) X_train <- RES_train %>% select(-status) %>% as.matrix(nrow = length(RES_train[,2]), ncol = ncol(RES_train)-1, byrow = TRUE) str(X_train)
participantes (2)
-
ASANTOS
-
Daniel Guimarães Tiezzi