hacking_religion_textbook/hacking_religion/docs/search.json

100 lines
20 KiB
JSON
Raw Normal View History

2023-10-02 10:51:32 +00:00
[
{
"objectID": "index.html",
"href": "index.html",
"title": "Hacking Religion: TRS & Data Science in Action",
"section": "",
"text": "Preface\nThis is a Quarto book.\nTo learn more about Quarto books visit https://quarto.org/docs/books."
},
{
"objectID": "intro.html#who-this-book-is-for",
"href": "intro.html#who-this-book-is-for",
"title": "1  Introduction: Hacking Religion",
"section": "1.1 Who this book is for",
"text": "1.1 Who this book is for"
},
{
"objectID": "intro.html#why-this-book",
"href": "intro.html#why-this-book",
"title": "1  Introduction: Hacking Religion",
"section": "1.2 Why this book?",
"text": "1.2 Why this book?"
},
{
"objectID": "intro.html#the-hacker-way",
"href": "intro.html#the-hacker-way",
"title": "1  Introduction: Hacking Religion",
"section": "1.3 The hacker way",
"text": "1.3 The hacker way\n\nTell the truth\nDo not deceive using beauty\nWork transparently: research as open code using open data\nDraw others in: produce reproducible research\nLearn by doing"
},
{
"objectID": "intro.html#why-programmatic-data-science",
"href": "intro.html#why-programmatic-data-science",
"title": "1  Introduction: Hacking Religion",
"section": "1.4 Why programmatic data science?",
"text": "1.4 Why programmatic data science?\nThis isnt just a book about data analysis, Im proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that youll gain access to a set of tools and a research philosophy which is much more powerful."
},
{
"objectID": "intro.html#learning-to-code-my-way",
"href": "intro.html#learning-to-code-my-way",
"title": "1  Introduction: Hacking Religion",
"section": "1.5 Learning to code: my way",
"text": "1.5 Learning to code: my way\nThis guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, or whatever, such that it was weeks before I got to actually do anything. I know some people, may prefer this approach, but I dramatically prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so its not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices Ive made and the way Ive structured things. Each chapter focusses on a problem which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a “deep dive” when you feel like it. Otherwise, Ill take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice.\nThere are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, Id recommend that many readers will want to check out Hadley Wickhams “R For Data Science” book. Ill include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail."
},
{
"objectID": "intro.html#getting-set-up",
"href": "intro.html#getting-set-up",
"title": "1  Introduction: Hacking Religion",
"section": "1.6 Getting set up",
"text": "1.6 Getting set up\nEvery single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the “hacker way”) theyve made these tools freely available. This also means that you arent restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. Ill make a few opinionated recommendations here based on my own preferences and experience, but its really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools youve found that you want to share with others.\nThere are, right now, primarily two languages that statisticians and data scientists use for this kind of programmatic data science: python and R. Each language has its merits and I wont rehash the debates between various factions. For this book, well be using the R language. This is, in part, because the R user community and libraries tend to scale a bit better for the work that Im commending in this book. However, its entirely possible that one could use python for all these exercises, and perhaps in the future well have volume two of this book outlining python approaches to the same operations.\nBearing this in mind, the first step youll need to take is to download and install R. You can find instructions and install packages for a wide range of hardware on the The Comprehensive R Archive Network (or “CRAN”): https://cran.rstudio.com. Once youve installed R, youve got some choices to make about the kind of programming environment youd like to use. You can just use a plain text editor like textedit to write your code and then execute your programs using the R software youve just installed. However, most users, myself included, tend to use an integrated development environment (or “IDE”). This is usually another software package with a guided user interface and some visual elements that make it faster to write and test your code. Some IDE packages, will have built-in reference tools so you can look up options for libraries you use in your code, they will allow you to visualise the results of your code execution, and perhaps most important of all, will enable you to execute your programs line by line so you can spot errors more quickly (we call this “debugging”). The two most popular IDE platforms for R coding at the time of writing this textbook are RStudio and Visual Studio. You should download and try out both and stick with your favourite, as the differences are largely aesthetic. I use a combination of RStudio and an enhanced plain text editor Sublime Text for my coding.\nOnce you have R and your pick of an IDE, you are ready to go! Proceed to the next chapter and well dive right in and get started!"
},
{
"objectID": "chapter_1.html",
"href": "chapter_1.html",
"title": "2  The 2021 UK Census",
"section": "",
"text": "References"
},
{
"objectID": "chapter_1.html#your-first-project-building-a-pie-chart",
"href": "chapter_1.html#your-first-project-building-a-pie-chart",
"title": "2  The 2021 UK Census",
"section": "2.1 Your first project: building a pie chart",
"text": "2.1 Your first project: building a pie chart\nLets start by importing some data into R. Because R is what is called an object-oriented programming language, well always take our information and give it a home inside a named object. There are many different kinds of objects, which you can specify, but usually R will assign a type that seems to fit best.\nIf youd like to explore this all in a bit more depth, you can find a very helpful summary in R for Data Science, chapter 8, “data import”.\nIn the example below, were going to read in data from a comma separated value file (“csv”) which has rows of information on separate lines in a text file with each column separated by a comma. This is one of the standard plain text file formats. R has a function you can use to import this efficiently called “read.csv”. Each line of code in R usually starts with the object, and then follows with instructions on what were going to put inside it, where that comes from, and how to format it:\n\n# R Setup -----------------------------------------------------------------\nsetwd(\"/Users/kidwellj/gits/hacking_religion_textbook/hacking_religion\")\nlibrary(here) # much better way to manage working paths in R across multiple instances\n\nhere() starts at /Users/kidwellj/gits/hacking_religion_textbook\n\nlibrary(tidyverse)\n\n-- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --\nv dplyr 1.1.3 v readr 2.1.4\nv forcats 1.0.0 v stringr 1.5.0\nv ggplot2 3.4.3 v tibble 3.2.1\nv lubridate 1.9.3 v tidyr 1.3.0\nv purrr 1.0.2 \n\n\n-- Conflicts ------------------------------------------ tidyverse_conflicts() --\nx dplyr::filter() masks stats::filter()\nx dplyr::lag() masks stats::lag()\ni Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors\n\nhere::i_am(\"chapter_1.qmd\")\n\nhere() starts at /Users/kidwellj/gits/hacking_religion_textbook/hacking_religion\n\nreligion_uk <- read.csv(here(\"example_data\", \"census2021-ts030-rgn.csv\")) \n\n\n2.1.1 Examining data:\nWhats in the table? You can take a quick look at either the top of the data frame, or the bottom using one of the following commands:\n\nhead(religion_uk)\n\n geography total no_religion christian buddhist hindu jewish\n1 North East 2647012 1058122 1343948 7026 10924 4389\n2 North West 7417397 2419624 3895779 23028 49749 33285\n3 Yorkshire and The Humber 5480774 2161185 2461519 15803 29243 9355\n4 East Midlands 4880054 1950354 2214151 14521 120345 4313\n5 West Midlands 5950756 1955003 2770559 18804 88116 4394\n6 East 6335072 2544509 2955071 26814 86631 42012\n muslim sikh other no_response\n1 72102 7206 9950 133345\n2 563105 11862 28103 392862\n3 442533 24034 23618 313484\n4 210766 53950 24813 286841\n5 569963 172398 31805 339714\n6 234744 24284 36380 384627\n\n\nThis is actually a fairly ugly table, so Ill use an R tool called kable to give you prettier tables in the future, like this:\n\nknitr::kable(head(religion_uk))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ngeography\ntotal\nno_religion\nchristian\nbuddhist\nhindu\njewish\nmuslim\nsikh\nother\nno_response\n\n\n\n\nNorth East\n2647012\n1058122\n1343948\n7026\n10924\n4389\n72102\n7206\n9950\n133345\n\n\nNorth West\n7417397\n2419624\n3895779\n23028\n49749\n33285\n563105\n11862\n28103\n392862\n\n\nYorkshire and The Humber\n5480774\n2161185\n2461519\n15803\n29243\n9355\n442533\n24034\n23618\n313484\n\n\nEast Midlands\n4880054\n1950354\n2214151\n14521\n120345\n4313\n210766\n53950\n24813\n286841\n\n\nWest Midlands\n5950756\n1955003\n2770559\n18804\n88116\n4394\n569963\n172398\n31805\n339714\n\n\nEast\n6335072\n2544509\n2955071\n26814\n86631\n42012\n234744\n24284\n36380\n384627\n\n\n\n\n\nYou can see how Ive nested the previous command inside the kable command. For reference, in
},
{
"objectID": "chapter_1.html#making-your-first-chart",
"href": "chapter_1.html#making-your-first-chart",
"title": "2  The 2021 UK Census",
"section": "2.2 Making your first chart",
"text": "2.2 Making your first chart\nWeve got a nice lean set of data, so now its time to visualise this. Well start by making a pie chart:\n\nwmids_data <- wmids_data %>% select(no_religion:no_response)\nwmids_data <- gather(wmids_data)\n\nThere are two basic ways to do visualisations in R. You can work with basic functions in R, often called “base R” or you can work with an alternative library called ggplot:\n\n2.2.0.1 Base R\n\ndf <- wmids_data[order(wmids_data$value,decreasing = TRUE),]\nbarplot(height=df$value, names=df$key)\n\n\n\n\n\n\n2.2.0.2 GGPlot\n\n# unsorted\nggplot(wmids_data, aes(x = key, y = value)) +\n geom_bar(stat = \"identity\")\n\n\n\n# with sorting added in\nggplot(wmids_data, aes(x= reorder(key,-value),value)) + geom_bar(stat =\"identity\")\n\n\n\n\nClean up chart features\nAdd time series data for 2001 and 2011 census, change to grouped bar plot:\nhttps://r-graphics.org/recipe-bar-graph-grouped-bar#discussion-8\n\n\n\n\n\n\n\nWhat is Religion?\n\n\n\nContent tbd\n\n\n\n\n\n\n\n\nHybrid Religious Identity\n\n\n\nContent tbd\n\n\n\n\n\n\n\n\nWhat is Secularisation?\n\n\n\nContent tbd"
},
{
"objectID": "chapter_2.html",
"href": "chapter_2.html",
"title": "3  Survey Data: Spotlight Project",
"section": "",
"text": "In the last chapter we explored some high level data about religion in the UK. This was a census sample, which usually refers to an attempt to get as comprehensive a sample as possible. But this is actually fairly unusual in practice. Depending on how complex a subject is, and how representative we want our data to be, its much more common to use selective sampling, that is survey responses at n=100 or n=1000 at a maximum. The advantage of a census sample is that you can explore how a wide range of other factors - particularly demographics - intersect with your question. And this can be really valuable in the study of religion, particularly as you will see as we go along that responses to some questions are more strongly correlated to things like economic status or educational attainment than they are to religious affiliation. It can be hard to tell if this is the case unless you have enough of a sample to break down into a number of different kinds of subsets. But census samples are complex and expensive to gather, so theyre quite rare in practice.\nFor this chapter, Im going to walk you through a data set that a colleague (Charles Ogunbode) and I collected in 2021. Another problem with smaller, more selective samples is that researchers can often undersample minoritised ethnic groups. This is particularly the case with climate change research. Until the time we conducted this research, there had not been a single study investigating the specific experiences of people of colour in relation to climate change in the UK. Past researchers had been content to work with large samples, and assumed that if they had done 1000 surveys and 50 of these were completed by people of colour, they could “tick” the box. But 5% is actually well below levels of representation in the UK generally, and even more sharply the case for specific communities. And if we bear in mind that non-white respondents are (of course!) a highly heterogenous group, were even more behind in terms of collecting data that can improve our knowledge. Up until recently researchers just havent been paying close enough attention to catch the significant neglect of the empirical field that this represents.\nWhile Ive framed my comments above in terms of climate change research, it is also the case that, especially in diverse societies like the USA, Canada, the UK etc., paying attention to non-majority groups and people and communities of colour automatically draws in a strongly religious sample. This is highlighted in one recent study done in the UK, the “Black British Voices Report” in which the researchers observed that “84% of respondents described themselves as religious and/or spiritual”. My comments above in terms of controlling for other factors remains important here - these same researchers also note that “despire their significant important to the lives of Black Britons, only 7% of survey respondents reported that their religion was more defining of their identity than their race”.\nWeve decided to open up access to our data and Im highlighting it in this book because its a unique opportunitiy to explore a dataset that emphasises diversity from the start, and by extension, provides some really interesting ways to use data science techniques to explore religion in the UK.\n\n\n\n\n\n\nHow can we measure religion?\n\n\n\nContent tbd\n\n\n\nReferences"
},
{
"objectID": "chapter_3.html",
"href": "chapter_3.html",
"title": "4  Mapping churches: geospatial data science",
"section": "",
"text": "Guides to geographies: https://rconsortium.github.io/censusguide/ https://ocsi.uk/2019/03/18/lsoas-leps-and-lookups-a-beginners-guide-to-statistical-geographies/\n\nReferences"
},
{
"objectID": "chapter_4.html",
"href": "chapter_4.html",
"title": "5  Data scraping, corpus analysis and wordclouds",
"section": "",
"text": "References"
},
{
"objectID": "summary.html",
"href": "summary.html",
"title": "6  Summary",
"section": "",
"text": "An open textbook introducing data science to religious studies"
}
]