title: R Extracting table from web, without <span class="hidden">
body: <p>I am trying to scrap results of Polish elections that were held this weekend, but I come to problem that before every intager random float is added.</p>
  
  <p>I have tried using <code>htmltab</code>, but it did not work - as you can see random number is added</p>
  
  <pre><code>library(htmltab)
  url &lt;- "https://wybory2018.pkw.gov.pl/pl/geografia/020000#results_vote_council"
  tmp &lt;- htmltab::htmltab(doc = html, which = 1) 
  tmp
  
    Wyszczególnienie              Liczba
  2      Mieszkańców 0.972440432 755 957
  3         Wyborców 0.977263472 273 653
  4          Obwodów      0.99998061 940
  </code></pre>
  
  <p>I have checked in html what is the problem:</p>
  
  <pre><code>library(xml2)
  library(rvest)
  webpage &lt;- xml2::read_html(url)
  a &lt;- webpage %&gt;%
    rvest::html_nodes("tbody") 
  
  a[1]
  
  &lt;tbody&gt;\n&lt;tr&gt;\n&lt;td&gt;Mieszkańców&lt;/td&gt;\n                            &lt;td class=\"table-number\"&gt;\n&lt;span class=\"hidden\"&gt;0.97244043&lt;/span&gt;2 755 957&lt;/td&gt;\n                        &lt;/tr&gt;\n&lt;tr&gt;\n&lt;td&gt;Wyborców&lt;/td&gt;\n                            &lt;td class=\"table-number\"&gt;\n&lt;span class=\"hidden\"&gt;0.97726347&lt;/span&gt;2 273 653&lt;/td&gt;\n                        &lt;/tr&gt;\n&lt;tr&gt;\n&lt;td&gt;Obwodów&lt;/td&gt;\n                            &lt;td class=\"table-number\"&gt;\n&lt;span class=\"hidden\"&gt;0.9999806&lt;/span&gt;1 940&lt;/td&gt;\n                        &lt;/tr&gt;\n&lt;/tbody&gt;"
  </code></pre>
  
  <p>I assume the problem is with <code>&lt;span class=\"hidden\"&gt;</code>, but how to get rid of it?</p>
  
  <h2>EDIT</h2>
  
  <p>I need the info from the 9th table with results of the parties</p>
  
  <pre><code>Nr listy  Komitet wyborczy  Liczba  % głosów ważnych
  Głosów na kandydatów komitetu Kandydatów    
  12  KOMITET WYBORCZY WYBORCÓW Z DUTKIEWICZEM DLA DOLNEGO ŚLĄSKA 93 260  45  8.29% 
  9 KOMITET WYBORCZY WYBORCÓW WOLNOŚĆ W SAMORZĄDZIE 15 499  46  1.38% 
  8 KOMITET WYBORCZY WYBORCÓW KUKIZ'15  53 800  41  4.78% 
  1 KOMITET WYBORCZY WYBORCÓW BEZPARTYJNI SAMORZĄDOWCY  168 442 46  14.98%  
  11  KOMITET WYBORCZY WOLNI I SOLIDARNI  9 624 38  0.86% 
  7 KOMITET WYBORCZY RUCH NARODOWY RP 14 874  38  1.32% 
  10  KOMITET WYBORCZY PRAWO I SPRAWIEDLIWOŚĆ 320 908 45  28.53%  
  2 KOMITET WYBORCZY POLSKIE STRONNICTWO LUDOWE 58 820  46  5.23% 
  6 KOMITET WYBORCZY PARTII RAZEM 18 087  44  1.61% 
  3 KOMITET WYBORCZY PARTIA ZIELONI 19 783  36  1.76% 
  5 KOALICYJNY KOMITET WYBORCZY SLD LEWICA RAZEM  61 889  46  5.50% 
  4 KOALICYJNY KOMITET WYBORCZY PLATFORMA.NOWOCZESNA KOALICJA OBYWATELSKA 289 831 46  25.77%  
  </code></pre>
  
  <h2>EDIT 2</h2>
  
  <p>I have found not the most elegant solution:</p>
  
  <pre><code>#https://stackoverflow.com/questions/7963898/extracting-the-last-n-characters-from-a-string-in-r
  substrRight &lt;- function(x, n){
    substr(x, nchar(x)-n+1, nchar(x))
  }
  
  tmp &lt;- htmltab::htmltab(doc = html, which = 9) 
  
  tmp2 &lt;- xml2::read_html(html) %&gt;%
    rvest::html_nodes("tbody") %&gt;%
    magrittr::extract2(9)  %&gt;%
    rvest::html_nodes("tr") %&gt;%
    rvest::html_nodes("td") %&gt;%
    rvest::html_nodes("span") %&gt;%
    rvest::html_text() %&gt;%
    matrix(ncol = 4, byrow = T) %&gt;%
    data.frame() 
  
  names(tmp) &lt;- c("a", "b", "c", "d", "e", "f", "g")
  tmp3 &lt;- cbind(tmp, tmp2) %&gt;%
    mutate(n_to_delate = nchar(X1),
           c1 = as.character(c),
           n_whole = nchar(c1),
           c2 = substrRight(c1, n_whole - n_to_delate),
           c3 = gsub(" ", "", c2),
           c4 = as.numeric(c3)) %&gt;%
    select(b, c4)
  
  names(tmp3) &lt;- c("party", "n_of_votes")
  </code></pre>