Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.
Soon after Trump’s tariffs were announced, it was noted the ‘reciprocal’ tariffs looked suspiciously like the US trade deficit divided by imports.
Ever the skeptic, I couldn’t believe it could be this simple, so I decided to check it out myself with the help of R and UN Comtrade data. Here’s my answer, neatly documented in R code.
If you’re interested in reproducing this analysis you’ll need to get an API key for the comtradr package.
Code block: project setup:
#load packages library(googlesheets4) library(tidyverse) library(countrycode) library(comtradr) #set comtrade api key set_primary_comtrade_key(ref_comtrade_api_key) ref_gsheet_url<-"https://docs.google.com/spreadsheets/d/1AbPFX21KKfiCr8WWA6fwfPVKAjE5MUCzdWVitV0ZuWM/edit?usp=sharing" #read data from google sheet dta_us_tariffs<-read_sheet(ref_gsheet_url) #add countrycodes dta_us_tariffs<- dta_us_tariffs |> mutate(iso3c= countrycode(sourcevar=country, origin="country.name", destination="iso3c")) #assign _KS as as code for Kosovo as per Comtrade country code list (KSV is also used by some providers) dta_us_tariffs[dta_us_tariffs$country=="Kosovo","iso3c"]<-"_KS" #create reference list of focus countries ref_focus_countries<-dta_us_tariffs$iso3c # get bilateral trade data for US dta_comtrade <- ct_get_data( reporter = 'USA', partner=dta_us_tariffs$iso3c, commodity_code = 'TOTAL', start_date = 2024, end_date = 2024, flow_direction = c('import','export') ) # select focus variables and round to billion USD dta_comtrade<-dta_comtrade |> select(ref_year,partner_iso,flow_desc,fobvalue) |> mutate(fobvalue= fobvalue/10^9) # Pivot dataframe by flow type dta_comtrade<-dta_comtrade |> pivot_wider(names_from=flow_desc, values_from = fobvalue) #calculate trade balance dta_comtrade<-dta_comtrade |> mutate(trade_bal= Export- Import, trade_bal_to_m_ratio= round(trade_bal/Import,2)*100) #join comtrade data with tariff listing dta_us_tariffs_and_trade_flows<-left_join(dta_us_tariffs,dta_comtrade, by=c('iso3c'="partner_iso"))
There’s more I’d like to do with this data, but for now I thought I’d share my code and the answer: yes. The reciprocal tariffs look almost identical to the trade balance to imports ratio.
@carlbergstrom.com has a great thread (skeet?) on this on Bluesky.

Code block:
#create filtered dataframe where tariff > standard rate #drop EU countries as individual reciprocal tariffs weren't published dta_plt_us_tariffs<- dta_us_tariffs_and_trade_flows |> filter(us_tariffs_applied >10, EU == "N") #plot where tariff != reciprocal tariff plt_us_tariffs<-ggplot(data=dta_plt_us_tariffs, aes(y=us_claimed_reciprocal_tariff, x=trade_bal_to_m_ratio))+ geom_text(aes(label =iso3c), size=2)+ theme_minimal()+ labs(x= "Imports / Trade Balance (%)", y="Announced 'Reciprocal' Tariff") plt_us_tariffs
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you’re looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.
Continue reading: Calculating the United State’s ‘reciprocal’ tariffs
Analyzing the Implications of Trump’s ‘Reciprocal’ Tariffs
The post examines whether Trump’s reciprocal tariffs, announced as a response to perceived unfair trade policies from other nations, resemble the U.S. trade deficit divided by imports. The author utilizes R programming and the UN Comtrade data to support their analysis.
Key Observations
After applying the R code to the relevant data sets, the author found that the reciprocal tariffs indeed mirrored the U.S. trade deficit to import ratio, confirming their initial suspicions.
Long-Term Implications and Future Developments
Tariffs, as utilized in Trump’s trade policies, are a contentious issue. They have the potential to disrupt global economic stability and strain international relationships, thereby bringing unforeseen consequences in the long term.
Effect on Global Trade Relations
By imposing duties on goods from countries with which the U.S. has a trade deficit, it can lead to trade wars, which are often detrimental to both sides. Countries on the receiving end of these tariffs might respond in kind, inflating prices for consumers and hampering economic growth.
Economic Impact
While such tariffs might initially seem to be beneficial for the domestic economy by discouraging imports, they can lead to retaliation, higher prices, and decreased economic activity. Exporters may also suffer as foreign markets become less accessible due to reciprocal tariffs.
Actionable Advice
Navigating such complex economic dynamics requires careful consideration and planning. Here are some recommendations based on the analysis:
- Educated Decision Making: Policymakers should consider the full implications of tariffs on the economy and global trade relations. This includes taking into account the retaliation risk and possible harm to domestic industries dependent on international trade.
- Data-Driven Approach: Accurate information is critical for crafting sound economic and trade policies. Governments and policymakers should use data and analytic tools, like R programming, to achieve a comprehensive understanding of the situation and craft policies.
- Multilateral Negotiations: Rather than unilateral tariff impositions, engaging in multilateral negotiations can lead to more beneficial trade agreements for all parties involved. This approach may deescalate potential trade conflicts and facilitate a more stable global trade environment.
Conclusion
Understanding the full implications and repercussions of trade policies like reciprocal tariffs requires a thorough analysis of trade data and trends. While tariffs might be useful tools for addressing trade imbalances, they must be employed with caution considering their potential to disrupt global trade and economic stability.