Constitutions as Data (II): Identifying the Constitutionalization of Weapons Through Word Frequency Counts

Different Approaches to Firearm Regulation

The regulation of firearms is often controversial, but more than half of the constitutions in the world have some sort of language referring to firearms. In offering these protections, countries must balance property rights, protections against tyranny, public safety, and a handful of other considerations. To do so, there is often a need to coordinate with multiple levels of government.  

Most countries throughout the world mention firearms in their constitutions. However, these countries do so in many different ways. In the examples discussed here, some offer a right to firearm possession, others offer a limited right to possession, while some simply assign the responsibility to a certain level of government.

This blog post will identify how different constitutions regulate gun ownership and analyze these articles. In doing so, it will plot the years in which constitutions that refer to firearms were adopted, identify a few limitations, and then further analyze the wording of these protections in three countries. These countries are the USA, Mexico, and Austria. Of note, all three regulate firearms differently.

Term Frequency Counts

In this post, we will use a simple function from the “stringr” package called str_count() to count the frequency of specific terms in constitutions. We could have also used regular expressions covered in Lesson 3 or build a term-frequency matrix as done in Lesson 5. The advantage of the str_count() function is that it directly counts all matches of the word or pattern that is being looked up. Since “stringr” is not part of the R base, we have to install and activate the package.


Counting Firearm Mentions

This analysis builds on a previous post about patterns in the adoption of constitutions around the world. As such, if you want to consult how we uploaded and cleaned up the data, you can do so by viewing that post or doing Lesson 1 and Lesson 2 on our website.               

We start by asking which country’s constitution mentions firearms most frequently. To answer that question, we count firearms mentions in all constitutions.

constitution_texts$firearm<- str_count(constitution_texts$text, "firearm|Firearm")

We can then check which constitutions mention firearms the most.


It turns out that Palau mentions the term 4 times in its constitution – more than any other state. A look at its constitution reveals that it regulates firearms very strictly.

Article 12 

The national government shall have exclusive power to regulate importation of firearms and ammunition. No persons except armed forces personnel lawfully in Palau and law enforcement officers acting in an official capacity shall have the right to possess firearms or ammunition unless authorized by legislation which is approved in a nationwide referendum by a majority of the votes cast on the issue.

Tracing Patterns over Time

Some constitutions use terms related to firearms. To track trends over time, we expand our search to include all the relevant terminology.

constitution_texts$firearm<- str_count(constitution_texts$text, "firearm|Firearm|firearms|Firearms|arms|Arms")

The next step is to create a smaller data frame that shows what constitutions use firearm-related language and list the years they were adopted. Here, we take three columns out of our original data frame to create a smaller and more manageable data frame without the full text. These three columns consist of whether the word “firearm” is used, the country that used it, and the year they adopted their constitution. Then, we provide intuitive headers for each column.

#Create a smaller data frame to better present the data and provide more mangeable data to make a plot
GunperCountry <-[,3:5])
colnames(GunperCountry) <- c( "Adopted","Country","firearm")

Next, we create a subset of this dataset to determine what years the constitutions with firearm-related language were adopted and tally how many constitutions use this language. The subset() function eliminates all the countries that do not use fire-arm related terminology from this new data frame. Then, the table() function shows us how many constitutions with the desired terminology were adopted each year.

ConstiGun <- subset(GunperCountry, GunperCountry$firearm > 0)
ConstiGunPerYear <- table(ConstiGun$Adopted)

Finally, we will plot the data. The graph can be modified quite easily by adapting the parameters on each line of the code. Of note, you may adjust the xlim = and ylim = sections of the code to zoom in or out on a certain pattern.

FirearmsPlot <- plot(ConstiGunPerYear, xlim = c(1775,2020),ylim=c(1,10),ylab = "Use of the word 'firearm'", xlab = "Year", type = "h",                        main = "'Firearm' or Similar Term by Year of Adoption", lwd=2.5)

Here, we will zoom in on the pattern by selecting constitutions adopted since 1950. We changed the x-axis of the graph by changing the setting in “xlim =”.

FirearmsPlotSince1950 <- plot(ConstiGunPerYear, 
                     xlim = c(1950,2020),ylim=c(1,15),ylab =                                           
                     "Use of the word 'firearm'", xlab = "Year", 
                     type = "h",main = "'Firearm' or Similar 
                     Term by Year of Adoption", lwd=2.5)

More than half of the constitutions, 103 to be exact, use the word firearm or a related word at least once. The pattern of their adoption largely resembles the number of constitutions that were adopted each year we discussed in the previous post exhibiting a peak in the early 1990s.   


One limitation of this research is that many countries use language like “arms” to describe things other than firearms. For instance, article 12(4) of the Romanian constitution states that “The coat of arms of the country and the state seal are established by organic laws.” This shows that often terminology is used in a way that is different from the way you might assume when approaching a problem.


In the following section, we will pull three different examples of ways in which constitutions regulate firearms. We will see that there are absolute rights, limited rights, and constitutions that simply categorize it within the division of powers. It is possible that a more fulsome review of these rights would identify even more categories.


The first type of constitutional firearm protection is an individual right to possess firearms. This right is relatively rare globally. Famously, the United States has a provision in its constitution which offers this protection :

Article 2 (excerpt)  

A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed

The United States Supreme Court has recently, in its 2008 Heller decisions, interpreted the above clause as permitting Americans to own firearms that are unconnected to a well-regulated militia or military service. As such, American citizens have the right to keep arms for personal use without the state being allowed to impose many limits on gun-ownership.


The Mexican constitution is another document that protects firearm ownership. However, this protection can be limited by the government. As such, the right to own firearms can be limited as follows :

Article 10  

The inhabitants of the United Mexican States have the right to keep arms at home, for their protection and legitimate defense, with the exception of those prohibited by the Federal Law and those reserved for the exclusive use of the Army, Navy, Air Force, and National Guard. Federal Law will state the cases, conditions, requirements and places where inhabitants can be authorized to carry weapons.

Similar rights to the one Mexico offers its citizen are available in many other countries. Absent a Federal Law limiting gun ownership, Mexican citizens may own guns. However, this right can be fully restricted by their federal government.


Finally, the Austrian constitution provides no right to firearm ownership. Instead, it deals with firearms solely as a division of powers issue. Here, there is no individual right to keep or use firearms.

Article 10

The Federation has powers of legislation and execution in the following matters:  

(7) the maintenance of peace, order and security including the extension of primary assistance in general, but excluding local public safety matters; the right of association and assembly; matters pertaining to personal status, including the registration of births, marriages and deaths, and change of name; aliens police and residence registration; matters pertaining to weapons, ammunition and explosives, and the use of fire-arms;


The use of language pertaining to firearms can lead to many different things. As we’ve seen above, this can be a quasi-total right to own firearms, a right that can be limited by the government, or just that firearms are regulated by a certain level of government.  This, in turn, highlights a limitation of text-as-data analysis. These types of analyses help us identify certain types of language. They do not, however, allow us to make assumptions about what the meaning of this language is. To uncover meaning, it is usually necessary to have a human read the material carefully. The next post helps us solve part of the problem, by allowing us to extract context.

access_time Last update July 6, 2020.

chat networking coding local-network layer menu folders diagram panel route line-chart compass search flow data-sharing search-1 message target translator candidates studying chat networking coding local-network layer menu folders diagram panel route line-chart compass search flow data-sharing search-1 message target translator candidates studying