Sample Code – R

A big part of quantitative and social networks research involves accepting one major thing as fact:
my code sucks, and that’s okay!

It’s not specific to my code–all code sucks, and approaching coding with the assumption that no code is perfect is an important step towards participating in the crowd-sourcing practices that are vital to platforms, like R, that are user-driven. It’s also useful for modeling. Just as no code is perfect, no model is perfect, but you have to practice both coding and modeling to obtain results. This means that your results are, similarly, not perfect. Learning to embrace coding and modeling, including the failed code and models, as informative parts of the research process is useful when interpreting the science. For me, it is one of the ways I check my own biases as a social scientist, a constant reminder that “facts” are not objective or static.

The files available on this page demonstrate my process during the “learning” stage of a research project, when still learning the structure and components of the data. The files do not contain final code executed for the projects, nor do they contain final results.

All code and analysis was executed using RStudio desktop for Mac (Intel, Big Sur). Code and output files were composed as R notebooks and converted to pdf format.

Please feel free to borrow and share for your own purposes!

Natural Language Processing and Latent Dirichlet Allocation (LDA)

Quantitative text analysis using text from tweets about masks posted to Twitter during March 2020

Exit mobile version