将网页中的表格转换为数据框

问题描述 投票:0回答:1

我正在寻找一种解决方案,将网页中的数据表

u
(请参阅下面的详细信息)复制到数据框中。我的代码很短,因为我很难弄清楚如何从
w
中获取该表:

library(rvest)

u <- paste0("https://www.frbservices.org/resources/financial-services/securities/",
            "volume-value-stats/quarterly-stats.html")

w <- read_html(u)
html r rvest
1个回答
0
投票
w |> 
  html_node("table") |> 
  html_table()

产量:

# A tibble: 128 × 9
   Quarter Transfers originated1\n   …¹ Quarterly volume gro…² Value of transfers o…³
   <chr>   <chr>                        <chr>                  <chr>                 
 1 2023:Q4 6,843,936                    6.6                    116,793,254           
 2 2023:Q3 6,418,535                    2.0                    111,273,018           
 3 2023:Q2 6,293,096                    1.3                    109,076,373           
 4 2023:Q1 6,213,620                    10.7                   97,327,236            
 5 2022:Q4 5,612,418                    2.4                    86,085,772            
 6 2022:Q3 5,481,321                    3.2                    87,175,922            
 7 2022:Q2 5,313,329                    2.3                    85,977,539            
 8 2022:Q1 5,193,156                    9.0                    82,567,500            
 9 2021:Q4 4,765,993                    5.5                    79,546,935            
10 2021:Q3 4,515,630                    (5.6)                  75,480,685            
# ℹ 118 more rows
# ℹ abbreviated names: ¹​`Transfers originated1\n   (number)`,
#   ²​`Quarterly volume growth\n   (percent)`,
#   ³​`Value of transfers originated\n   ($millions)`
# ℹ 5 more variables: `Quarterly value growth\n   (percent)` <chr>,
#   `Average value per transfer\n   ($millions)` <dbl>,
#   `Average daily volume of transfers2\n   (number)` <chr>, …
© www.soinside.com 2019 - 2024. All rights reserved.