I have been exploring the rvest package and have a question regarding extracting urls from a list. My goal is to generate a df with the following headers: Country, City and the URL for the city. I already have a df with each of the countries and a list with the cities for each country.
My question is, how can I reference each city so that I can obtain its respective URL link? I am trying to reference the href …
我正在尝试从列中删除 $ 符号和 , ,到目前为止一直通过使用 gsub 来做到这一点,但我想知道是否有一种方法可以在管道内使用 stringr 来做到这一点。
示例代码:
DataFrame <- structure(list(Date = structure(c(18485, 18459, 18471, 18459,
18459, 18459, 18499, 18513, 18513, 18513), class = "Date"), Payment = c("$10,000.00",
"$2,000.00", "$500.00", "$500.00", "$5,000.00", "$4,000.00",
"$5,000.00", "$500.00", "$20,000.00", "$3,290.00")), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))
Run Code Online (Sandbox Code Playgroud)
当前使用 gsub 的方法:
DataFrame$Payment <-gsub("\\$","",DataFrame$Payment)
DataFrame$Payment <-gsub("\\,","",DataFrame$Payment)
DataFrame$Payment <- as.numeric(DataFrame$Payment)
Run Code Online (Sandbox Code Playgroud)
感谢您的指点!