Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a data frame #6

Open
mvuorre opened this issue Jul 15, 2017 · 2 comments
Open

Return a data frame #6

mvuorre opened this issue Jul 15, 2017 · 2 comments

Comments

@mvuorre
Copy link

mvuorre commented Jul 15, 2017

Great package! Would it be possible to add an option to return a data frame instead of a knitr_kable object?

If text_stats() returned a df, it would be easier to use in the document itself to grab the word count. This way it could be used to automatically insert word counts to documents.

Cheers.

@benmarwick
Copy link
Owner

Thanks, yes, that should be straightforward. I currently have the unexported function wordcountaddin:::text_stats_fn_(text) but it returns a list rather than a data frame. I'll have a go at an exported function that returns a data frame. That's a great idea to use it to insert the word count in a doc!

@gaardhus
Copy link

gaardhus commented Nov 27, 2022

In case anybody else still wants this functionality I use a kind of hacky workaround and just parse the HTML table outputted by the function.

ts = as.data.frame(
    wordcountaddin::text_stats() %>%
        as.character() %>%
        read_html() %>%
        html_table(fill = TRUE)
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants