有没有办法编辑您抓取的 tibble 的值?

Is there a way to edit the values of a tibble that you've scraped?

我从 USGS 网站上抓取了河流流量数据,流量数据附有字母 A、P 或 E,以显示实际、预测或估计的流量。有没有办法截断数据,使其不显示 A、P、and/or E?

flows_raw <- "https://waterdata.usgs.gov/ut/nwis/dv?cb_00060=on&format=html&site_no=10163000&referred_module=sw&period=&begin_date=2010-10-14&end_date=2020-10-14" %>%
  read_html() %>%
  html_nodes("table") %>%
  .[2] %>%
  html_table() %>%
  .[[1]] %>%
  as_tibble()
flows_raw

嗯,我自己解决了,但如果有人有更简洁的方法,我仍然很乐意看到它。

   flows_raw <- "https://waterdata.usgs.gov/ut/nwis/dv?cb_00060=on&format=html&site_no=10163000&referred_module=sw&period=&begin_date=2008-11-14&end_date=2020-10-14" %>%
  read_html() %>%
  html_nodes("table") %>%
  .[2] %>%
  html_table() %>%
  .[[1]] %>%

  # remove extraneous info from the values marked by the letters A, P, or E

  separate(`Dis-charge, ft3/s,(Mean)`, into = c("edit1", "extra"), convert = TRUE, sep = "A") %>% 
  separate(edit1, into = c("edit2", "extra"), convert = TRUE, sep = "P") %>% 
  separate(edit2, into = c("Cubic Ft/Sec (mean)", "extra"), convert = TRUE, sep = "E") %>% 

  # delete the column that we moved the A, P, and E's into
  
  select(-extra) %>%
  as_tibble()