alicirce / marxmywords

Capital by Karl Marx in a tidy text format ready for data analysis in R

Home Page:https://alicirce.github.io/marxmywords/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

marxmywords

Capital, or Das Kapital, published in 1867 by Karl Marx, is one of the most important economic texts of the 19th century. This package makes it available for text analysis in R!

Installation

You can install the development version of marxmywords like so:

devtools::install_github("alicirce/marxmywords")

Example

After loading the package, the text should be available in your namepace. Let's peek at the table of contents:

library(marxmywords)
library(dplyr)
capital_vol1 %>%
  filter(section == "toc")

This object is a dataframe. The text itself is stored in the column text, the other columns indicate which section, part and chapter the text came from. Read more about the structure and source of this data frame in the package documentation:

help(capital_vol1)

If you'd like to print it out to a text file to read as a book, there is a convenience function:

book <- capital_vol1_book()
writeLines(book, "capital_vol1.txt")

Or you can count the number of occurrences of a word:

capital_vol1 %>%
  mutate(
    n_linen = stringr::str_count(text, "linen"),
    n_coat  = stringr::str_count(text, "coat"),
  ) %>%
  summarize(
    tot_linen = sum(n_linen),
    tot_coat  = sum(n_coat)
  )

About

Capital by Karl Marx in a tidy text format ready for data analysis in R

https://alicirce.github.io/marxmywords/

License:Other


Languages

Language:R 100.0%