How to read and make dataframe with this data?

Viewed 27

I need to read and create an dataframe with R from this url https://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-extended-latest, but I confess that I cannot go much far than this...

# R packages
library(tidyverse)
library(dplyr)
library(rvest)

and...

url <- "https://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-extended-latest"

page<- read_html(url)
page

{html_document}
<html>
[1] <body><p>2.3|lacnic|20220922|84615|19870101|20220922|-0300\nlacnic|*|ipv4 ...

I tryed to use rvest to find tables but...

tables <- page %>%
  html_table(fill=TRUE) 

tables

list()

My expected dataframe result is something like

In other words, using the | as sep ... How can I extract this data and convert it for an R dataframe ?

2 Answers

Try this:

 url <- "https://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-extended-latest"
    
    
    df <- read.delim(url(url), sep = "|", row.names = NULL)
df <- readr::read_delim(
   file = "https://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-extended-latest",
   delim = "|",
   col_names = F
)
Related