Full_Join list of lists of data frames

I have read multiple urls from a site and now have a list of lists of data frames (tbl). How can I full_join these lists of data frames into one data frame.


library(xml2)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(purrr)
library(rvest)
#> 
#> Attaching package: 'rvest'
#> The following object is masked from 'package:purrr':
#> 
#>     pluck


url <- file.path(str_c("https://amx.am/en/9/trading/10/instruments", '?page=', 1:3))
#> Error in str_c("https://amx.am/en/9/trading/10/instruments", "?page=", : could not find function "str_c"

tbl <- lapply(url, read_html) %>% lapply(html_table)
#> Error in UseMethod("read_xml"): no applicable method for 'read_xml' applied to an object of class "name"

Created on 2020-01-25 by the reprex package (v0.3.0)

Hi, I'm not totally sure about your expected output here, but one thing you could do is to use purrr::reduce() annd dplyr::bind_rows() to combine all the data frames in your list. Not sure if it makes sense to combine all these columns based on the data, but this is how you would do it. Also note that your reprex above returned an error because you didn't attach all the packages that you used in your code.

library(purrr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(rvest)
#> Loading required package: xml2
#> 
#> Attaching package: 'rvest'
#> The following object is masked from 'package:purrr':
#> 
#>     pluck
library(stringr)

url <- file.path(str_c("https://amx.am/en/9/trading/10/instruments", '?page=', 1:3))

tbl <- lapply(url, read_html) %>%
  lapply(html_table)

tbl %>% 
  reduce(bind_rows) %>% 
  head()
#>                 X1                                             X2
#> 1           Ticker                                        0N60294
#> 2           Issuer Ministry of Finance of the Republic of Armenia
#> 3             ISIN                                   AMGN60294201
#> 4  Admittance date                                     29.04.2015
#> 5            Class                                    Coupon bond
#> 6 Listing category                                          Gbond

Created on 2020-01-25 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.