Giter Club home page Giter Club logo

Comments (5)

leeper avatar leeper commented on September 12, 2024

Try setting method = "data.frame". If you have a well-formed table, that should return a very nice data.frame with column names specified and row names as a column.

from tabulizer.

pssguy avatar pssguy commented on September 12, 2024

The table i am sourcing from looks well formed but it comes out as a list even when stipulating as a data.frame and when I coerce to data.frame the first row becomes the column headings

library(tidyverse)
library(tabulizer)
 extract_tables("https://crashstats.nhtsa.dot.gov/Api/Public/ViewPublication/812293", pages = 3, method="data.frame") %>% 
    as.data.frame()

I'm on v 0.1.22

from tabulizer.

leeper avatar leeper commented on September 12, 2024

@pssguy It's a list of data.frames:

> str(.)
List of 1
 $ :'data.frame':       52 obs. of  10 variables:
  ..$ Alabama: chr [1:52] "Alaska " "Arizona " "Arkansas " "California " ...
  ..$ X820   : chr [1:52] "73 " "770 " "466 " "3,074 " ...
  ..$ X4.849 : chr [1:52] "737 " "6,731 " "2,966 " "38,803 " ...
  ..$ X3.882 : chr [1:52] "532 " "4,882 " "2,112 " "24,813 " ...
  ..$ X5.367 : chr [1:52] "800 " "5,588 " "2,779 " "28,687 " ...
  ..$ X65.667: chr [1:52] "4,857 " "62,631 " "34,024 " "332,857 " ...
  ..$ X16.91 : num [1:52] 9.91 11.44 15.71 7.92 9.11 ...
  ..$ X21.13 : chr [1:52] "13.73 " "15.77 " "22.07 " "12.39 " ...
  ..$ X15.28 : num [1:52] 9.12 13.78 16.77 10.72 10.12 ...
  ..$ X1.25  : num [1:52] 1.5 1.23 1.37 0.92 1 0.8 1.26 0.65 1.24 1.04 ...

Just extract the first element using [[ to get the data frame you want

from tabulizer.

pssguy avatar pssguy commented on September 12, 2024

@leeper thansk for reply but I still haven't got it

 crash <- extract_tables("https://crashstats.nhtsa.dot.gov/Api/Public/ViewPublication/812293", pages = 3, method="data.frame") 

 crash[[1]]
                 Alabama    X820   X4.849   X3.882   X5.367    X65.667 X16.91 X21.13 X15.28 X1.25
1                Alaska      73      737      532      800      4,857    9.91 13.73    9.12  1.50

from tabulizer.

oldi avatar oldi commented on September 12, 2024

It has to be output = "data.frame" - not method.

from tabulizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.