I want to grab content in the url while the original data come in simple column and row. I tried readHTMLTable and obviously its not working. Using webcsraping xpath, how to get clean data without '\n...' and keep the data in data.frame. Is this possible without saving in csv? kindly help me to improve my code. Thank you
library(rvest)
library(dplyr)
page <- read_html("http://weather.uwyo.edu/cgi-bin/sounding?region=seasia&TYPE=TEXT%3ALIST&YEAR=2006&MONTH=09&FROM=0100&TO=0100&STNM=48657")
xpath <- '/html/body/pre[1]'
txt <- page %>% html_node(xpath=xpath) %>% html_text()
txt
[1] "\n-----------------------------------------------------------------------------\n   PRES   HGHT   TEMP   DWPT   RELH   MIXR   DRCT   SKNT   THTA   THTE   THTV\n    hPa     m      C      C      %    g/kg    deg   knot     K      K      K \n-----------------------------------------------------------------------------\n 1009.0     16   23.8   22.7     94  17.56    170      2  296.2  346.9  299.3\n 1002.0     78   24.6   21.6     83  16.51    252      4  297.6  345.6  300.5\n 1000.0     96   24.4   21.3     83  16.23    275      4  297.6  344.8  300.4\n  962.0    434   22.9   20.0     84  15.56    235     10  299.4  345.0  302.1\n  925.0    777   21.4   18.7     85  14.90    245     11  301.2  345.2  303.9\n  887.0   1142   20.3   16.0     76  13.04    255     15  303.7  342.7  306.1\n  850.0   1512   19.2   13.2     68  11.34    230     17  306.2  340.6  308.3\n  839.0   1624   18.8   11.8     64  10.47    225     17  307.0  338.8  308.9\n  828.0   1735   18.0   11.4     65  10.33   ... <truncated>
 
     
    