The peeps dataset will be used to generate a small gt table containing only the people born in the 1980s. The country column contains 3-letter country codes and those will be transformed to country names with fmt_country().
Use the countrypops dataset to create a gt table. We will only include a few columns and rows from that table. The country_code_3 column has 3-letter country codes in the format required for fmt_country() and using that function transforms the codes to country names.
The country names derived from country codes can be localized. Let’s translate some of those country names into three different languages using different locale values in separate calls of fmt_country().
Let’s make another gt table, this time using the films dataset. The countries_of_origin column contains 2-letter country codes and some cells contain multiple countries (separated by commas). We’ll use fmt_country() on that column and also specify that the rendered country names should be separated by a comma and a space character. Also note that historical country codes like "SU" (‘USSR’), "CS" (‘Czechoslovakia’), and "YU" (‘Yugoslavia’) are permitted as inputs for fmt_country().
films |> dplyr::filter(year ==1959) |> dplyr::select(contains("title"), run_time, director, countries_of_origin, imdb_url ) |>gt() |>tab_header(title ="Feature Films in Competition at the 1959 Festival") |>fmt_country(columns = countries_of_origin, sep =", ") |>fmt_url(columns = imdb_url,label = fontawesome::fa("imdb", fill ="black") ) |>cols_merge(columns =c(title, original_title, imdb_url),pattern ="{1}<< ({2})>> {3}" ) |>cols_label(title ="Film",run_time ="Length",director ="Director",countries_of_origin ="Country" ) |>opt_vertical_padding(scale =0.5) |>opt_table_font(stack ="classical-humanist", weight ="bold") |>opt_stylize(style =1, color ="gray") |>tab_options(heading.title.font.size =px(26))
Feature Films in Competition at the 1959 Festival
Film
Length
Director
Country
Araya
1h 30m
Margot Benacerraf
Venezuela, France
Compulsion
1h 43m
Richard Fleischer
United States
Eva (Die Halbzarte)
1h 32m
Rolf Thiele
Austria
Fanfare
1h 26m
Bert Haanstra
Netherlands
Miss April (Fröken April)
1h 38m
Göran Gentele
Sweden
Arms and the Man (Helden)
1h 40m
Franz Peter Wirth
Germany
Hiroshima mon amour
1h 30m
Alain Resnais
France, Japan
Court Martial (Kriegsgericht)
1h 24m
Kurt Meisel
Germany
The Soldiers of Pancho Villa (La cucaracha)
1h 37m
Ismael Rodríguez
Mexico
Lajwanti
2h
Narendra Suri
India
The 400 Blows (Les quatre cents coups)
1h 39m
François Truffaut
France
Honeymoon (Luna de miel)
1h 49m
Michael Powell
United Kingdom, Spain
Bloody Twilight (Matomeno iliovasilemma)
1h 28m
Andreas Labrinos
Greece
Middle of the Night
1h 58m
Delbert Mann
United States
Nazarín
1h 34m
Luis Buñuel
Mexico
Black Orpheus (Orfeu Negro)
1h 40m
Marcel Camus
Brazil, France, Italy
A Home for Tanya (Otchiy dom)
1h 40m
Lev Kulidzhanov
USSR
Policarpo (Policarpo 'ufficiale di scrittura')
1h 44m
Mario Soldati
Italy, France, Spain
Portuguese Rhapsody (Rapsódia Portuguesa)
1h 26m
João Mendes
Portugal
Room at the Top
1h 57m
Jack Clayton
United Kingdom
A Midsummer Night's Dream (Sen noci svatojánské)
1h 16m
Jirí Trnka
Czechoslovakia
The Snowy Heron (Shirasagi)
1h 37m
Teinosuke Kinugasa
Japan
Stars (Sterne)
1h 31m
Konrad Wolf
East Germany, Bulgaria
The Sinner (Tang fu yu sheng nu)
1h 30m
Shen Tien
Taiwan
The Diary of Anne Frank
3h
George Stevens
United States
Desire (Touha)
1h 35m
Vojtech Jasný
Czechoslovakia
Train Without a Timetable (Vlak bez voznog reda)
2h 1m
Veljko Bulajic
Yugoslavia
Sugar Harvest (Zafra)
1h 17m
Lucas Demare
Argentina
Édes Anna
1h 24m
Zoltán Fábri
Hungary
Country names can sometimes pair nicely with flag-based graphics. In this example (using a different portion of the films dataset) we use fmt_country() along with fmt_flag(). The formatted country names are then merged into the same cells as the icons via cols_merge().