2 Freedom of Press Writings
On September 14, 1770, Christian VII issued a rescript granting full press freedom in Denmark-Norway and the duchies, ending the prior requirement that all writings be approved by University of Copenhagen censors. Initiated by Johann Friedrich Struensee, the reform ended with his execution in 1772, and true press freedom did not return until 1849. The surviving texts offer a rare glimpse into the autocratic society of the early 1770s and include everything from political and economic works to satire, fiction, gossip, and pornography. Government official Bolle Willum Luxdorph (1716–88) recognized the importance of this moment and privately collected these writings in 47 bound volumes. Digitised by the Royal Danish Library, the collection — analyzed by Ulrik Langen, Frederik Stjernfelt, and Henrik Horstbøl—will serve as the basis for using R to study word-use trends during this brief experiment in press freedom.
These pages are about processing the Freedom of the Press text as data and extracting indsights quantitatively. If you wannw read the texts the classical way you can see them at: https://tekster.kb.dk
2.1 Loading the data
2.1.1 Loading libraries
The dataset is processed in the software programme R, offering various methods for statistical analysis and graphic representation of the results. In R, one works with packages each adding numerous functionalities to the core functions of R. In this example, the relevant packages are:
2.1.2 Load Data
The code below reads data from a CSV file named “tfs_structured.csv” and stores it in a variable called tfs.
tfs <- read_csv("https://raw.githubusercontent.com/maxodsbjerg/TextMiningTFS/refs/heads/main/data/tfs_structured.csv")## Rows: 28133 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: ","
## chr (11): files, tekst, content, refnr, Titel, Bogtrykker/forlægger, Format, sider, Forfatter, Udg.år, Averteret, language
## dbl (3): række, bind, side
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Here’s a breakdown of what each part of the code does: * <-: The assignment operator in R assigns the result of the operation on the right-hand side to the variable on the left-hand side. * read_csv: This is a function in R that reads data from a CSV file. “data/tfs_structured.csv”: This is the file path where the CSV file is located. It tells R where to find the file. In this case, the file is located in a folder called “data” and its name is “tfs_structured.csv”. * tfs: This is the name of the variable where the data from the CSV file will be stored. Once the data is read, it will be accessible in R using this variable name. In summary, the code reads data from a CSV file named “tfs_structured.csv” and stores it in a variable called tfs, allowing the data to be manipulated and analyzed in R.
2.2 Converting to Tidy Text Format
This code takes the data stored in the variable tfs, which contains text data from Trykkefrihedens skrifter, and converts it into a tidy format suitable for text analysis.
Here’s a breakdown of the code: tfs_tidy: This is a new variable where the transformed data will be stored. tfs %>%: This is the pipe operator %>%, which is used to chain operations together in R. It takes the data frame tfs and passes it as the first argument to the function or operation that follows. unnest_tokens(word, content): This is a function call from the tidytext package. It tokenizes the text data, breaking it down into individual words. The word argument specifies the name of the column that will contain the individual words, and the content argument specifies the column containing the text data to be tokenized. In summary, the code transforms the original data frame tfs by breaking down the text data into individual words and storing them in a new variable called tfs_tidy, making it suitable for further text analysis tasks.
2.3 Analysis
2.3.1 Initial analysis
The code tfs_tidy %>% count(word, sort = TRUE) simply counts the frequency of each unique word in the tfs_tidy dataset, sorting the results in descending order based on word count.
## # A tibble: 22,581 × 2
## word n
## <chr> <int>
## 1 og 12073
## 2 at 8014
## 3 i 5560
## 4 til 4792
## 5 det 4566
## 6 som 4475
## 7 de 4296
## 8 en 3702
## 9 den 3688
## 10 er 3455
## # ℹ 22,571 more rows
Alot of stopwords, which are are common words like “og”, “den”, and “det” that are often filtered out during text analysis because they don’t add significant meaning. In the code tfs_tidy %>% count(word, sort = TRUE), it counts all words, including stopwords, which may clutter the results with less informative words. Lets sort them out.
2.3.2 Handling Stopword
This code chunk creates a tibble named stopord_da containing Danish stopwords. The function stopwords(“da”) retrieves a list of common stopwords in the Danish language. The tibble stopord_da will have a single column named “word” containing the Danish stopwords.
This code chunk creates a tibble named stopord_de containing German stopwords. Similar to the previous chunk, the function stopwords(“de”) retrieves a list of common stopwords in the German language. The tibble stopord_de will have a single column named “word” containing the German stopwords.
stopord_tfs <- read_csv("https://raw.githubusercontent.com/maxodsbjerg/TextMiningTFS/refs/heads/main/data/tfs_stopord.csv")## Rows: 60 Columns: 1
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): word
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
This code chunk reads data from a CSV file named “tfs_stopord.csv” located in the “./data” directory. The function read_csv() reads the CSV file and assigns the data to the variable stopord_tfs. This file likely contains stopwords specific to the dataset or project being analyzed. The structure of the data will be similar to a tibble, with one column containing the stopwords. These stop words are specifically tailored for Trykkefrihedens Skrifter, considering older spelling conventions of stop words. ### Removing stopwords and counting again:
This code performs several operations on the tfs_tidy dataset, which contains tokenized text data:
tfs_tidy %>%
anti_join(stopord_da) %>%
anti_join(stopord_de) %>%
anti_join(stopord_tfs) %>%
count(word, sort = TRUE)## Joining with `by = join_by(word)`
## Joining with `by = join_by(word)`
## Joining with `by = join_by(word)`
## # A tibble: 166,534 × 2
## word n
## <chr> <int>
## 1 gud 5781
## 2 tid 4711
## 3 mere 4425
## 4 imod 4418
## 5 vore 4303
## 6 store 4273
## 7 folk 4269
## 8 2 4257
## 9 stor 4086
## 10 intet 4052
## # ℹ 166,524 more rows
tfs_tidy %>%: The %>% operator, known as the pipe operator, chains operations together, passing the tfs_tidy dataset to the next function in the sequence. anti_join(stopord_da) %>%: This operation removes Danish stopwords from the text data by performing an anti-join with the stopord_da dataset, which contains Danish stopwords. An anti-join retains only the rows from the left dataset (tfs_tidy) that do not have a match in the right dataset (stopord_da). anti_join(stopord_de) %>%: Similarly, this operation removes German stopwords from the text data by performing an anti-join with the stopord_de dataset, which contains German stopwords. anti_join(stopord_tfs) %>%: This operation removes project-specific stopwords from the text data by performing an anti-join with the stopord_tfs dataset, which contains stopwords specific to the Trykkefrihedens Skrifter project. count(word, sort = TRUE): Finally, the count() function tallies the frequency of each unique word remaining in the text data after removing the stopwords. The sort = TRUE argument sorts the results in descending order of word frequency. In summary, this code chunk filters out Danish, German, and project-specific stopwords from the tfs_tidy dataset and then counts the frequency of the remaining words.
This does the exact same thing, but only on text from Række 1, binde 5+6 (Landøkonomi (31 skrifter).)
tfs_tidy %>%
anti_join(stopord_da) %>%
anti_join(stopord_de) %>%
anti_join(stopord_tfs) %>%
count(word, sort = TRUE)## Joining with `by = join_by(word)`
## Joining with `by = join_by(word)`
## Joining with `by = join_by(word)`
## # A tibble: 166,534 × 2
## word n
## <chr> <int>
## 1 gud 5781
## 2 tid 4711
## 3 mere 4425
## 4 imod 4418
## 5 vore 4303
## 6 store 4273
## 7 folk 4269
## 8 2 4257
## 9 stor 4086
## 10 intet 4052
## # ℹ 166,524 more rows
2.3.3 Keywords in Context (KWIC) Analysis
In this code we are going to conduct a ‘Keywords in Context’ (KWIC) analysis on the text data from Trykkefrihedens Skrifter using the quanteda package. This analysis will allow us to examine how specific keywords, such as ‘jord’, are used within the text documents, providing valuable insight into the context and usage patterns of these keywords throughout the corpus.
#Creating quanteda corpus
tfs_corp <- tfs %>%
#Choose Række and Bind of choice
filter(række == 1 & bind %in% c(5,6)) %>%
select(refnr, side, content) %>%
corpus(text_field = "content")## Warning: NA is replaced by empty string
# Assign docid to the corpus - makes it easier to track the actual text back to Trykkefrihedens skrifter
docid <- paste0(tfs_corp$refnr, "- side ", tfs_corp$side)
docnames(tfs_corp) <- docid
#Keywords in context
tfs_kwic <- tfs_corp %>%
tokens() %>%
#Choose phrase of interest
kwic(pattern = phrase("jord"), window = 4)
tfs_kwic## Keyword-in-context with 199 matches.
## [1.5.1- side 39, 166] enhver Bonde havde sin | Jord | for sig selv afdeelt
## [1.5.1- side 40, 7] han skal giøde sin | Jord | , ei bortføre mere
## [1.5.1- side 40, 62] naar han havde sin | Jord | for sig selv beliggende
## [1.5.2- side 33, 201] Steen, Tang, | Jord | & c..
## [1.5.2- side 38, 28] overlade ham min Eyendoms | Jord | og Grund, for
## [1.5.2- side 50, 163] falde paa den allerbeste | Jord | i Markerne, andres
## [1.5.2- side 50, 190] at han fik mere | Jord | i sit Maal,
## [1.5.2- side 50, 216] megen og slet ufrugtbar | Jord | for den, som
## [1.5.2- side 50, 238] svare: Den slette | Jord | kan ved Flid og
## [1.5.2- side 51, 104] etableres paa den dyrkværdige | Jord | , som skulde anvendes
## [1.5.2- side 52, 15] Maade. At Bøndernes | Jord | for hver Gaards Hartkorn
## [1.5.2- side 52, 145] Lods-Eyer har mere samlet | Jord | i Markerne, end
## [1.5.2- side 52, 215] Sæd: Den yderste | Jord | , som er længst
## [1.5.2- side 53, 106] Størrelse, al den | Jord | , som de nu
## [1.5.2- side 54, 131] hver fik al sin | Jord | , som den tilkom
## [1.5.2- side 54, 190] benytte sig af sin | Jord | : al Jorden bekom
## [1.5.2- side 55, 224] ; thi jo mindre | Jord | Bonden har, jo
## [1.5.2- side 56, 49] : meget af hans | Jord | bliver da kuns maadelig
## [1.5.2- side 56, 106] Gaarden og saa megen | Jord | forsømt, til stor
## [1.5.2- side 56, 186] , efter 4 Slags | Jord | , saaledes: Den
## [1.5.2- side 56, 195] 1ste og beste Slags | Jord | , hvoraf beregnes paa
## [1.5.2- side 56, 213] Tønders Udsæd, eller | Jord | af 42000 Qvadrat Alen
## [1.5.2- side 57, 18] 6 Tønders Udsæd eller | Jord | af 84000 Qvadrat Alen
## [1.5.2- side 57, 45] 9 Tønders Udsæd eller | Jord | af 126000 Qvadrat Alens
## [1.5.2- side 57, 71] første og beste Slags | Jord | , kan med egen
## [1.5.2- side 57, 82] en Plov forsvarlig drive | Jord | idet høyeste til 5
## [1.5.2- side 57, 155] 2de første Slags Sæde | Jord | , som er af
## [1.5.3- side 17, 3] 17 bryde | Jord | op til Agerland,
## [1.5.3- side 18, 86] hver Bye fik sin | Jord | for sig selv,
## [1.5.3- side 18, 119] enhver Bonde blev udlagt | Jord | til en fuldkommen Frugthave
## [1.5.3- side 19, 11] han har saa megen | Jord | , som kan give
## [1.5.3- side 29, 152] maa lade sin egen | Jord | ligge udyrket, og
## [1.5.3- side 30, 212] af de øvrige Bønders | Jord | i Brug; for
## [1.5.3- side 31, 19] faae enhver Bonde sin | Jord | udmaalet og tildeelt;
## [1.5.4- side 57, 44] Legeme skal blive til | Jord | , hvoraf det er
## [1.5.5- side 4, 98] Luft, Vand og | Jord | , jo indeholder al
## [1.5.5- side 7, 77] Stene, eller sandig | Jord | , hvorudi var indblandet
## [1.5.5- side 7, 152] af de Stene, | Jord | eller andre Bergarter,
## [1.5.5- side 10, 16] , Havtang og Qvarksandagtig | Jord | , med mere deslige
## [1.5.5- side 53, 103] men dog indeholder Dyrkningsværdig | Jord | , af saadan Beskaffenhed
## [1.5.5- side 58, 122] fremsettende eller antreffende Salpeterfødende | Jord | ; Derimod udi sterk
## [1.5.5- side 62, 201] indlegges to Skiepper Salpeter | Jord | , samt 1/
## [1.5.5- side 68, 199] Hartkorn som den brugende | Jord | vr at sat i
## [1.5.5- side 102, 61] , Jordbakker, flad | Jord | og Vande, nemlig
## [1.5.5- side 107, 23] og Landmaalings Redskaber; | Jord | - og Berg-Boerer;
## [1.5.5- side 124, 112] Luft, Vand og | Jord | ( Steenriget dermed indbegreben
## [1.5.6- side 8, 44] , uden hvilket hverken | Jord | , Guld eller Sølv
## [1.5.6- side 8, 80] kunde eye en Strækning | Jord | af en Snees Miile
## [1.5.6- side 26, 12] , ligesom en ufrugtbar | Jord | ved Dyrkelse bringes til
## [1.5.6- side 38, 66] ikke Dyrkelsen af vor | Jord | det første, som
## [1.5.7- side 6, 84] kun en ringe Plet | Jord | er i Følge med
## [1.5.7- side 6, 106] Boeliger forsynede med noget | Jord | Brug, lidet eller
## [1.5.7- side 10, 108] a ) Hidtil udyrket | Jord | findes paa adskillige Stæder
## [1.5.7- side 11, 2] 9 | Jord | for sig selv.
## [1.5.7- side 11, 19] er at have sin | Jord | omkring sin Gaard,
## [1.5.7- side 11, 55] , at den beste | Jord | ofte ligger saa langt
## [1.5.7- side 11, 144] Paa denne allerede dyrkede | Jord | kunde boe flere Familier
## [1.5.7- side 12, 80] have i Almindelighed mere | Jord | end de NB.
## [1.5.7- side 13, 100] hver Vang. Denne | Jord | skulde inddeeles i saa
## [1.5.7- side 19, 66] er det nogenlunde god | Jord | og man kand overkomme
## [1.5.7- side 20, 19] indføres Huusmanden deeler sin | Jord | i 6 Agre,
## [1.5.7- side 22, 158] Gaard skulle miste mere | Jord | end en anden,
## [1.5.7- side 22, 170] fik mere eller bedre | Jord | end
## [1.5.7- side 27, 25] Bondegaard burde have faamegen | Jord | , som med 6
## [1.5.8- side 31, 3] 31 Huusbondens | Jord | , som derved ville
## [1.5.8- side 37, 88] behandler og dyrker sin | Jord | , eller hvorledes hans
## [1.5.9- side 37, 17] dets Sted et Stykke | Jord | i hver af Byens
## [1.5.9- side 48, 165] Gaard og dyrke deres | Jord | , med videre.
## [1.5.10- side 51, 217] bruger noget af Bondens | Jord | , og saadant;
## [1.5.11- side 12, 17] om ikke den hele | Jord | har almindelige, langsomme
## [1.6.1- side 7, 61] Beboere bortfæstet eller leiet | Jord | . 3. )
## [1.6.1- side 7, 135] tilfælles indhegnet en Strekning | Jord | fra det almindelige Fælleskab
## [1.6.1- side 9, 35] blandede i andre Byers | Jord | , endskiønt hver Mand
## [1.6.1- side 9, 86] have saare liden god | Jord | , som nu ligger
## [1.6.1- side 9, 96] imellem den paagrændsende Byes | Jord | ; og den skal
## [1.6.1- side 9, 109] er den anden Byes | Jord | , som ligger iblant
## [1.6.1- side 9, 132] end deres egen øvrige | Jord | . Hvo der veed
## [1.6.1- side 9, 232] et desstørre Stykke slet | Jord | . Vel bør denne
## [1.6.1- side 9, 245] , naar en Mands | Jord | skal vurderes til Skat
## [1.6.1- side 10, 5] 10 valent kan slet | Jord | aldrig blive for god
## [1.6.1- side 10, 10] aldrig blive for god | Jord | . Den slette store
## [1.6.1- side 10, 34] Strekning af den gode | Jord | , og hvad den
## [1.6.1- side 10, 139] den ringe Andeel god | Jord | , som Byen maaskee
## [1.6.1- side 11, 12] , og fremmede Byers | Jord | udskiftet, førend der
## [1.6.1- side 13, 152] Beboere faae al deres | Jord | paa Sandbanker, eller
## [1.6.1- side 14, 39] Længde har indtaget mere | Jord | at dyrke, da
## [1.6.1- side 14, 168] Mand kan faae sin | Jord | tildelt paa eet Sted
## [1.6.1- side 14, 217] som faaer al sin | Jord | paa Sandbanker, eller
## [1.6.1- side 14, 243] har ikkun eet slags | Jord | , blive i Stand
## [1.6.1- side 15, 3] 15 slags | Jord | imod, som han
## [1.6.1- side 15, 19] , som faae deres | Jord | tildeel; længst bort
## [1.6.1- side 15, 179] . Skal al Byens | Jord | deles om, og
## [1.6.1- side 15, 188] hver faae al sin | Jord | paa eet Sted,
## [1.6.1- side 16, 18] med mere. Ingen | Jord | vil det Aar blive
## [1.6.1- side 16, 33] han beholder ikke den | Jord | , som han skal
## [1.6.1- side 18, 185] et særdeles got Stykke | Jord | , som hans Fællesbrødre
## [1.6.1- side 20, 190] , foretager en Byes | Jord | efter den anden,
## [1.6.1- side 21, 44] meget muelig lige god | Jord | , hvorefter Gierdets Sted
## [1.6.1- side 21, 64] der ikke faae god | Jord | igien, eller ved
## [1.6.1- side 21, 75] Gierdet gaaer over deres | Jord | , erstattes dem af
## [1.6.1- side 21, 181] have indhegnet deres beqvemmeste | Jord | , og derover allerede
## [1.6.1- side 24, 139] og tilmaales hver sin | Jord | , samlet paa eet
## [1.6.1- side 25, 128] den inddeler al Byens | Jord | i fem eller sex
## [1.6.1- side 25, 206] antegner, hvor megen | Jord | hver Mand i Byen
## [1.6.1- side 26, 48] Ager og faaer udreven | Jord | igien, tillegges visse
## [1.6.1- side 26, 60] den som faaer giødet | Jord | for udreven; Den
## [1.6.1- side 26, 221] . legges den nærmeste | Jord | ved Byen, og
## [1.6.1- side 26, 246] har faaet kiendelig bedre | Jord | end andre, faaer
## [1.6.1- side 27, 145] herefter, hvor eens | Jord | ligger ved et andet
## [1.6.1- side 27, 195] , saa langt hans | Jord | strekker. Saa skal
## [1.6.1- side 27, 213] enten den hele Byes | Jord | , om han er
## [1.6.1- side 27, 223] Ejere, eller den | Jord | , som tilmaales hans
## [1.6.1- side 29, 11] imellem en Mands tilmaalte | Jord | , tildeles hannem og
## [1.6.1- side 30, 8] det første Aar den | Jord | , som da er
## [1.6.1- side 30, 40] følgende Aaringer den øvrige | Jord | , som hvert Aar
## [1.6.1- side 30, 126] det meste af deres | Jord | samlet paa eet Sted
## [1.6.1- side 31, 130] Huusmand tildeles et Stykke | Jord | i Udkant, hvor
## [1.6.1- side 51, 129] flye Karlen den beste | Jord | , rigelig Giødning,
## [1.6.2- side 14, 3] 14 trikulerede | Jord | ; Til Herregaardene derimod
## [1.6.2- side 67, 120] Sandhed, at en | Jord | , saasnart den bærer
## [1.6.2- side 67, 133] : At en maver | Jord | intet giver af sig
## [1.6.3- side 49, 228] ville drive al sin | Jord | paa ganske tilforn i
## [1.6.4- side 21, 29] korn i Straaet, | Jord | , Sand, Skuer
## [1.6.5- side 28, 64] ? Igel. Den | Jord | , Herren tog fra
## [1.6.5- side 28, 119] af denne dem fratagne | Jord | . Trekholt. Hvad
## [1.6.8- side 37, 121] Vandtuder, overklædte med | Jord | , naar Vandet ey
## [1.6.8- side 38, 111] , hvoraf det opkastede | Jord | , Gruus og Sand
## [1.6.9- side 9, 170] Almindelighed tillige al den | Jord | , som Bønderne boe
## [1.6.9- side 10, 9] der var overflødigt udyrket | Jord | , da de,
## [1.6.9- side 10, 83] ville antage denne Strækning | Jord | , bygget dem Huse
## [1.6.9- side 10, 160] ved at dyrke den | Jord | , som Eyeren af
## [1.6.9- side 12, 139] har betalt al den | Jord | , som Bønderne indehave
## [1.6.9- side 12, 163] og den dertil henlagte | Jord | ; Loven veed og
## [1.6.9- side 14, 145] hans til Bønderne uddeelte | Jord | ved deres Dyrkning indbringer
## [1.6.9- side 14, 152] Dyrkning indbringer, denne | Jord | : bliver ved Beboernes
## [1.6.9- side 15, 30] samt Redskaber til sin | Jord | og Huusholdning, maae
## [1.6.9- side 15, 46] det, som Hans | Jord | maatte indbringe ham anseeligst
## [1.6.9- side 15, 164] Almindelighed dyrekiøbte eller forhvervede | Jord | bort til een ham
## [1.6.9- side 16, 11] eller en Fods breed | Jord | , i Steden for
## [1.6.9- side 16, 92] , og saa meget | Jord | dertil, at han
## [1.6.9- side 21, 53] dem med hans Eyendoms | Jord | , som de bruge
## [1.6.9- side 23, 46] , at den forbedrede | Jord | ikke skal matriculeres Høyere
## [1.6.9- side 38, 122] sin ham allene tilhørende | Jord | i Fæste, saalænge
## [1.6.9- side 44, 20] da der i ringe | Jord | saaes mindre Korn,
## [1.6.9- side 44, 29] og skal pløyes desmere | Jord | til en Skieppe,
## [1.6.9- side 53, 24] lade meget af deres | Jord | ligge udyrket, og
## [1.6.9- side 54, 79] baade Nytte af Bøndernes | Jord | , om han selv
## [1.6.9- side 61, 130] , som Agerbond eller | Jord | , og hvad Regel
## [1.6.9- side 70, 161] til hans Gaard hørende | Jord | indhegnet for sig selv
## [1.6.9- side 71, 7] komme, hvor meget | Jord | bliver spildt ved Grøfterne
## [1.6.9- side 75, 139] , hvad enten deres | Jord | støder lige til Aaen
## [1.6.10- side 11, 189] Besidderen af den manglende | Jord | aldrig kunne undskylde sig
## [1.6.10- side 11, 212] den frugtbare, hvis | Jord | i denne Tilfælde ikke
## [1.6.10- side 14, 10] har en lige god | Jord | med sine Naboer,
## [1.6.10- side 27, 207] . Derved spartes megen | Jord | , som ellers gik
## [1.6.10- side 28, 127] den gode og fede | Jord | , maatte forpligtes til
## [1.6.11- side 8, 10] af den Grund og | Jord | , I have;
## [1.6.11- side 11, 95] fik al den gode | Jord | ved Byen, og
## [1.6.11- side 11, 133] . Hvad den gode | Jord | angaaer ved Byen,
## [1.6.11- side 12, 24] , at den slette | Jord | er, og det
## [1.6.11- side 15, 51] Fælledskabet. Naar saadan | Jord | bliver pløiet vaad,
## [1.6.11- side 23, 138] need i den sorte | Jord | , ja vent oprykket
## [1.6.11- side 24, 156] dyrker alt for megen | Jord | ; da det er
## [1.6.11- side 25, 77] man regne at hans | Jord | ikke faaer Giødning uden
## [1.6.11- side 27, 205] blande Frøet iblant fiin | Jord |
## [1.6.11- side 31, 158] fordeelagtig at have sin | Jord | samlet paa et Sted
## [ reached 'max' / getOption("max.print") -- omitted 33 rows ]
tfs_corp <- tfs_df %>% filter(række == 1 & bind %in% c(5,6)) %>% select(refnr, side, content) %>% corpus(text_field = “content”): This code filters the data frame tfs_df to include only rows where “række” equals 1 and “bind” is either 5 or 6. Then it selects columns “refnr,” “side,” and “content” from the filtered data and creates a corpus named tfs_corp using the corpus() function from the quanteda package, where “content” is the text field used in the corpus. docid <- paste0(tfs_corp\(refnr, "- side ", tfs_corp\)side): This line creates unique document IDs for each text document in the corpus by combining “refnr” and “side” columns separated by “- side”. docnames(tfs_corp) <- docid: This assigns the document IDs to the corpus, making it easier to track the original text back to Trykkefrihedens Skrifter. tfs_kwic <- tfs_corp %>% tokens() %>% kwic(pattern = phrase(“jord”), window = 4): This code generates a keyword-in-context (KWIC) analysis for the word “jord” with a window size of 4 words, which shows the context in which “jord” appears in the text documents within the corpus. The KWIC analysis provides insight into how the word is used and in what context within the text data.