[R-br] Dúvida para conversão de um output em *txt para data.frame usando tidyverse

Cid Póvoas cidedson em gmail.com
Ter Set 29 08:24:37 -03 2020


library(vroom)
library(tidyverse)
myfile <- vroom("
https://raw.githubusercontent.com/Leprechault/yolov3ants/master/yolov3-lca_416_conv81_sub_8_log.txt",
delim = "\t")
head(myfile)
str(myfile)

myfile <- myfile %>% rename(dados = `Prepare additional network for mAP
calculation...`)

myfile <- myfile %>% filter(str_detect(dados, c("avg", "Last accuracy")))

dim(myfile)
dim(myfile)

even_indexes <- seq(2, dim(myfile)[1], 2)
odd_indexes <- seq(1, dim(myfile)[1], 2)


x.dados <- tibble(x = myfile$dados[odd_indexes])
y.dados <- tibble(x = myfile$dados[even_indexes])

dim(x.dados)
dim(y.dados)

x.dados <- x.dados %>%
  separate(x, c("Last accuracy", "mAP"), sep = "=") %>%
  mutate_all(parse_number) %>%
  select("mAP") %>%
  as.data.frame()


y.dados <- y.dados %>%
  separate(x, c("interation", "avg_loss", "rate", "sec", "imgs"), sep =
c(",", ":")) %>%
  mutate_all(parse_number) %>%
  as.data.frame()

y.dados$id <- 1:dim(y.dados)[1]
x.dados$id <- 1:dim(x.dados)[1]

mydf <- merge(x.dados, y.dados, by="id")

mydf %>% filter(imgs == "101440")

mydf2 <- mydf %>% select(interation, avg_loss, mAP)


*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 seg., 28 de set. de 2020 às 18:19, ASANTOS por (R-br) <
r-br em listas.c3sl.ufpr.br> escreveu:

> Estou com um problema para criar um dataframe a partir de um conjunto de
> duas linhas de interesse, sendo:
> library(tidyverse)
> myfile<-read_lines(
> "https://raw.githubusercontent.com/Leprechault/yolov3ants/master/yolov3-lca_416_conv81_sub_8_log.txt"
> <https://raw.githubusercontent.com/Leprechault/yolov3ants/master/yolov3-lca_416_conv81_sub_8_log.txt>
> )
> head(myfile)
> Em algumas parte do meu arquivo eu tenho trechos que quero extrair que são
> :
> #Last accuracy mAP em 0.5 = 73.10 %
>
> #1585: 0.299288, 0.423193 avg loss, 0.001000 rate, 3.927486 seconds, 101440 images
> Nesses pontos eu quero remover as informações: mAP em 0.5 = 73.10 % (na
> primeira linha), 1585: e 0.423193 avg loss (da linha seguinte) e criar um
> data.frame final que seria:
> #  iteration avg_loss mAP
> #  1585      0.423193  73.10
> # ...
> mas quando tento remover a informação de interesse e por ser beginner no
> tidyverse, não tenho sucesso, sendo a minha tentativa na seguinte direção:
> names_col2 <- c("iteration", "avg_loss", "mAP")
> mydf <- myfile %>%
>   str_subset("Last accuracy mAP em 0.5 ="
> <Last%C2%A0accuracy%C2%A0mAP em 0.5%C2%A0=>) %>%
>   enframe(name = NULL) %>%
>   separate(col = value, into = names_col2, sep = "[=,]") %>%
>   mutate_all(parse_number)
> head(as.data.frame(mydf))
> Alguém poderia me dar uma luz?
> Obrigado,
> 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/
> --
>
> _______________________________________________
> R-br mailing list
> R-br em 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.
>
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20200929/6ff9b996/attachment.html>


Mais detalhes sobre a lista de discussão R-br