
library(tidyverse) library(vroom) myfile<-vroom(" https://raw.githubusercontent.com/Leprechault/trash/main/result_imgall_f_tes...", delim = "\t") myfile <- myfile %>% rename(dados = `Start processing imgall/sample_59178.jpg`) myfile$dados myfile %>% filter(str_detect(dados, "top|sample")) %>% filter(!str_detect(dados, "Predict")) %>% separate(dados, c("Start", "obj_id"), sep = "/") %>% as.data.frame() %>% mutate(Start = ifelse(Start == "Start processing imgall",NA,Start)) %>% separate(Start, c("lca", "left","top","width","height"), sep= ": ") %>% mutate_all(parse_number) %>% fill(., .direction = "downup", obj_id) %>% na.omit() %>% select(left, top,width,height,obj_id,lca) %>% mutate(obj_id = paste0("sample_",obj_id)) *Cid Edson Mendonça Póvoas **Cel: +55 (73) 99151-9565* *Engenheiro **Agrônomo* *Analista de dados * *Técnico em Segurança do Trabalho * *LinkedIn: **http://br.linkedin.com/in/cidedson/ <http://br.linkedin.com/in/cidedson/>* *Lattes: **http://lattes.cnpq.br/2303498368142537 <http://lattes.cnpq.br/2303498368142537>* Em qui., 12 de nov. de 2020 às 09:44, ASANTOS por (R-br) < r-br@listas.c3sl.ufpr.br> escreveu:
Bom dia Membros,
Eu gostaria de realizar a manipulação de um *txt para uso de algumas informações como variáveis em um data frame a ser criado. Em meu exemplo:
#Pacote library(tidyverse)
# Leitura do arquivo myfile<-read_lines(" https://raw.githubusercontent.com/Leprechault/trash/main/result_imgall_f_tes... ")
# Visualização parcial da informação contida no *txt # [1] "Start processing imgall/sample_59178.jpg" # [2] "imgall/sample_59178.jpg: Predicted in 7337.640000 milli-seconds." # [3] "End" # [4] "Start processing imgall/sample_34773.jpg" # [5] "imgall/sample_34773.jpg: Predicted in 7376.639000 milli-seconds." # [6] "End" # [7] "Start processing imgall/sample_24908.jpg" # [8] "imgall/sample_24908.jpg: Predicted in 7412.858000 milli-seconds." # [9] "End" #[10] "Start processing imgall/sample_18922.jpg" #[11] "imgall/sample_18922.jpg: Predicted in 7424.998000 milli-seconds." #[12] "End" #[13] "Start processing imgall/sample_31653.jpg" #[14] "imgall/sample_31653.jpg: Predicted in 7311.578000 milli-seconds." #[15] "lca: 90.681282%\tleft_x: 18\ttop_y: 33\twidth: 18\theight: 30" #[16] "End" #[17] "Start processing imgall/sample_17341.jpg" #[18] "imgall/sample_17341.jpg: Predicted in 7418.365000 milli-seconds." #[19] "End" #[20] "Start processing imgall/sample_11440.jpg" #[21] "imgall/sample_11440.jpg: Predicted in 7365.160000 milli-seconds." #[22] "lca: 66.567978%\tleft_x: 54\ttop_y: 34\twidth: 18\theight: 23" #[23] "lca: 33.219677%\tleft_x: 74\ttop_y: 15\twidth: 23\theight: 22" #[24] "End"
#Como output final eu gostaria de ter o seguinte dataframe:
#[1] left top width height obj_id lca #[2] 54 34 18 23 sample_11440 66.567978 #[3] 74 15 23 22 sample_11440 33.219677 #[4] 1 38 19 28 sample_40452 66.658073
#Estou tentando algo com o pacote tidyverse, mas sem sucesso e com muita dificuldade em isolar o que esta após "imgall/" e recuperar o que está contido após "\t" :
names_col <- c("left", "top", "width", "height", "obj_id","lca")
mydf <- myfile %>% str_subset("lca$") %>% enframe(name = NULL) %>% separate(col = value, into = names_col, sep = "[\t]") mydf # A tibble: 0 x 6 # ... with 6 variables: left <dbl>, top <dbl>, width <dbl>, height <dbl>, obj_id <dbl>, lca <dbl
#Dicas e/ou sugestões. Obrigado!
-- 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/ --
_______________________________________________ R-br mailing list R-br@listas.c3sl.ufpr.br https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.