The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
and constructs language-aware lists in R. It extends
the functionality of functions like knitr::combine_words()
and glue::glue_collapse()
to make and-separated
and or-separated lists that automatically conform to the user’s
R language settings.
You can install the released version of and from CRAN with:
install.packages("and")
or the development version of and from GitHub with:
# install.packages("pak")
::pkg_install("rossellhayes/and") pak
and()
creates “and”-separated lists from vectors.
<- c("John", "Paul", "George", "Ringo")
names and(names)
#> [1] "John, Paul, George, and Ringo"
But the Oxford comma is less common in other varieties of English, what happens if I change my R language to British English?
Sys.setenv(LANGUAGE = "en_GB")
and(names)
#> [1] "John, Paul, George and Ringo"
What about other languages?
Sys.setenv(LANGUAGE = "es")
and(names)
#> [1] "John, Paul, George y Ringo"
Sys.setenv(LANGUAGE = "eu")
and(names)
#> [1] "John, Paul, George eta Ringo"
Sys.setenv(LANGUAGE = "ko")
and(names)
#> [1] "John, Paul, George 및 Ringo"
Creating a list is not as simple as putting a different word between the last two items. For example, in Spanish, the word for and changes if the next word starts with an ⟨i⟩ or ⟨y⟩:
<- c("Vizzini", "Fezzik", "Inigo Montoya")
princess_bride Sys.setenv(LANGUAGE = "es")
and(princess_bride)
#> [1] "Vizzini, Fezzik e Inigo Montoya"
Everything and()
can do or()
can do better.
Just use or()
to create or-separated lists with
all the same contextual awareness.
<- c("win", "lose", "draw")
outcomes Sys.setenv(LANGUAGE = "en_US")
or(outcomes)
#> [1] "win, lose, or draw"
Sys.setenv(LANGUAGE = "ja")
or(outcomes)
#> [1] "win、lose、またはdraw"
Don’t want the language of you string to depend on the user’s
environment variables? You can explicitly set the language using the
language
argument.
and(names, language = "en_US")
#> [1] "John, Paul, George, and Ringo"
and(names, language = "en_GB")
#> [1] "John, Paul, George and Ringo"
and(names, language = "es")
#> [1] "John, Paul, George y Ringo"
and(names, language = "fr")
#> [1] "John, Paul, George et Ringo"
Language | Code | and example | or example |
---|---|---|---|
Afrikaans | af |
1, 2, 3 en 4 | 1, 2, 3 of 4 |
Albanian | sq |
1, 2, 3 dhe 4 | 1, 2, 3 ose 4 |
Amharic | am |
1፣ 2፣ 3, እና 4 | 1፣ 2፣ 3፣ ወይም 4 |
Arabic | ar |
1 و2 و3 و4 | 1 أو 2 أو 3 أو 4 |
Armenian | hy |
1, 2, 3 և 4 | 1, 2, 3 կամ 4 |
Assamese | as |
1, 2, 3 আৰু 4 | 1, 2, 3 বা 4 |
Asturian | ast |
1, 2, 3 y 4 | 1, 2, 3 o 4 |
Azerbaijani | az |
1, 2, 3 və 4 | 1, 2, 3, yaxud 4 |
Bangla | bn |
1, 2, 3 এবং 4 | 1, 2, 3, বা 4 |
Basque | eu |
1, 2, 3 eta 4 | 1, 2, 3 edo 4 |
Belarusian | be |
1, 2, 3 і 4 | 1, 2, 3 ці 4 |
Bosnian | bs |
1, 2, 3 i 4 | 1, 2, 3 ili 4 |
Breton | br |
1, 2, 3 ha 4 | 1, 2, 3 pe 4 |
Bulgarian | bg |
1, 2, 3 и 4 | 1, 2, 3 или 4 |
Burmese | my |
1 - 2 - 3နှင့် 4 | 1 - 2 - 3 သို့မဟုတ် 4 |
Cantonese | yue |
1、2、3同4 | 1、2、3 或 4 |
Catalan | ca |
1, 2, 3 i 4 | 1, 2, 3 o 4 |
Cebuano | ceb |
1, 2, 3, ug 4 | 1, 2, 3, o 4 |
Cherokee | chr |
1, 2, 3, ᎠᎴ 4 | 1, 2, 3, ᎠᎴᏱᎩ 4 |
Chinese | zh |
1、2、3和4 | 1、2、3或4 |
Chuvash | cv |
1, 2, 3 тата 4 | 1, 2, 3 е 4 |
Croatian | hr |
1, 2, 3 i 4 | 1, 2, 3 ili 4 |
Czech | cs |
1, 2, 3 a 4 | 1, 2, 3 nebo 4 |
Danish | da |
1, 2, 3 og 4 | 1, 2, 3 eller 4 |
Dutch | nl |
1, 2, 3 en 4 | 1, 2, 3 of 4 |
English (with Oxford comma) | en |
1, 2, 3, and 4 | 1, 2, 3, or 4 |
English (without Oxford comma) | en_GB et al.* |
1, 2, 3 and 4 | 1, 2, 3 or 4 |
Estonian | et |
1, 2, 3 ja 4 | 1, 2, 3 või 4 |
Faroese | fo |
1, 2, 3 og 4 | 1, 2, 3, ella 4 |
Filipino | fil |
1, 2, 3, at 4 | 1, 2, 3, o 4 |
Finnish | fi |
1, 2, 3 ja 4 | 1, 2, 3 tai 4 |
French | fr |
1, 2, 3 et 4 | 1, 2, 3 ou 4 |
Galician | gl |
1, 2, 3 e 4 | 1, 2, 3 ou 4 |
Georgian | ka |
1, 2, 3 და 4 | 1, 2, 3 ან 4 |
German | de |
1, 2, 3 und 4 | 1, 2, 3 oder 4 |
Greek | el |
1, 2, 3 και 4 | 1, 2, 3 ή 4 |
Gujarati | gu |
1, 2, 3 અને 4 | 1, 2, 3, અથવા 4 |
Hausa | ha |
1, 2, 3, da 4 | 1, 2, 3 ko 4 |
Hebrew | he |
1, 2, 3 ו4 | 1, 2, 3 או 4 |
Hindi | hi |
1, 2, 3, और 4 | 1, 2, 3 या 4 |
Hungarian | hu |
1, 2, 3 és 4 | 1, 2, 3 vagy 4 |
Icelandic | is |
1, 2, 3 og 4 | 1, 2, 3 eða 4 |
Indonesian | id |
1, 2, 3, dan 4 | 1, 2, 3, atau 4 |
Interlingua | ia |
1, 2, 3 e 4 | 1, 2, 3 o 4 |
Irish | ga |
1, 2, 3 agus 4 | 1, 2, 3 nó 4 |
Italian | it |
1, 2, 3 e 4 | 1, 2, 3 o 4 |
Japanese | ja |
1、2、3、4 | 1、2、3、または4 |
Javanese | jv |
1, 2, 3, lan 4 | 1, 2, 3, utowo 4 |
Kabuverdianu | kea |
1, 2, 3 i 4 | 1, 2, 3 o 4 |
Kaingang | kgp |
1, 2, 3 kar 4 | 1, 2, 3 ketũmỹr 4 |
Kannada | kn |
1, 2, 3, ಮತ್ತು 4 | 1, 2, 3, ಅಥವಾ 4 |
Kazakh | kk |
1, 2, 3, 4 | 1, 2, 3, не болмаса 4 |
Khmer | km |
1, 2, 3 និង 4 | 1, 2, 3 ឬ 4 |
Konkani | kok |
1, 2, 3, 4 | 1, 2, 3, वा 4 |
Korean | ko |
1, 2, 3 및 4 | 1, 2, 3 또는 4 |
Kurdish | ku |
1, 2, 3 û 4 | 1, 2, 3 an 4 |
Kyrgyz | ky |
1, 2, 3 жана 4 | 1, 2, 3 же 4 |
Lao | lo |
1, 2, 3, 4 | 1, 2, 3 ຫຼື 4 |
Latvian | lv |
1, 2, 3 un 4 | 1, 2, 3 vai 4 |
Lithuanian | lt |
1, 2, 3 ir 4 | 1, 2, 3 ar 4 |
Lower Sorbian | dsb |
1, 2, 3 a 4 | 1, 2, 3 abo 4 |
Macedonian | mk |
1, 2, 3 и 4 | 1, 2, 3 или 4 |
Malay | ms |
1, 2, 3 dan 4 | 1, 2, 3, atau 4 |
Malayalam | ml |
1, 2, 3, 4 എന്നിവ | 1, 2, 3, അല്ലെങ്കിൽ 4 |
Marathi | mr |
1, 2, 3 आणि 4 | 1, 2, 3, किंवा 4 |
Mongolian | mn |
1, 2, 3, 4 | 1, 2, 3, 4 зэргийн аль нэг |
Nepali | ne |
1,2, 3 र 4 | 1, 2, 3, वा 4 |
Nheengatu | yrl |
1, 2, 3 asuí 4 | 1, 2, 3 u 4 |
Nigerian Pidgin | pcm |
1, 2, 3, an 4 | 1, 2, 3 ọ 4 |
Norwegian | no |
1, 2, 3 og 4 | 1, 2, 3 eller 4 |
Norwegian Bokmål | nb |
1, 2, 3 og 4 | 1, 2, 3 eller 4 |
Norwegian Nynorsk | nn |
1, 2, 3 og 4 | 1, 2, 3 eller 4 |
Odia | or |
1, 2, 3, ଓ 4 | 1, 2, 3 କିମ୍ବା 4 |
Persian | fa |
1، 2، 3، و 4 | 1، 2، 3، یا 4 |
Polish | pl |
1, 2, 3 i 4 | 1, 2, 3 lub 4 |
Portuguese | pt |
1, 2, 3 e 4 | 1, 2, 3 ou 4 |
Punjabi | pa |
1, 2, 3 ਅਤੇ 4 | 1, 2, 3 ਜਾਂ 4 |
Quechua | qu |
1, 2, 3, 4 | 1, 2, 3, utaq 4 |
Romanian | ro |
1, 2, 3 și 4 | 1, 2, 3 sau 4 |
Romansh | rm |
1, 2, 3 e 4 | 1, 2, 3 u 4 |
Russian | ru |
1, 2, 3 и 4 | 1, 2, 3 или 4 |
Sardinian | sc |
1, 2, 3 e 4 | 1, 2, 3 o 4 |
Scottish Gaelic | gd |
1, 2, 3 agus 4 | 1, 2, 3 no 4 |
Serbian | sr |
1, 2, 3 и 4 | 1, 2, 3 или 4 |
Sindhi | sd |
1, 2, 3، ۽ 4 | 1, 2, 3, يا 4 |
Sinhala | si |
1, 2, 3, සහ 4 | 1, 2, 3, හෝ 4 |
Slovak | sk |
1, 2, 3 a 4 | 1, 2, 3 alebo 4 |
Slovenian | sl |
1, 2, 3 in 4 | 1, 2, 3 ali 4 |
Somali | so |
1, 2, 3 iyo 4 | 1, 2, 3 ama 4 |
Spanish | es |
1, 2, 3 y 4 | 1, 2, 3 o 4 |
Swahili | sw |
1, 2, 3 na 4 | 1, 2, 3 au 4 |
Swedish | sv |
1, 2, 3 och 4 | 1, 2, 3 eller 4 |
Syriac | syr |
1, 2, 3، ܘ4 | 1, 2, 3، ܝܐ 4 |
Tamil | ta |
1, 2, 3 மற்றும் 4 | 1, 2, 3 அல்லது 4 |
Telugu | te |
1, 2, 3 మరియు 4 | 1, 2, 3 లేదా 4 |
Thai | th |
1 2 3 และ4 | 1, 2, 3 หรือ 4 |
Tigrinya | ti |
1፣ 2፣ 3ን 4ን | 1፣ 2፣ 3 ወይ 4 |
Tongan | to |
1 mo 2 mo 3 mo 4 | 1, 2, 3, pē 4 |
Turkish | tr |
1, 2, 3 ve 4 | 1, 2, 3 veya 4 |
Turkmen | tk |
1, 2, 3 we 4 | 1, 2, 3 ýa-da 4 |
Ukrainian | uk |
1, 2, 3 і 4 | 1, 2, 3 або 4 |
Upper Sorbian | hsb |
1, 2, 3 a 4 | 1, 2, 3 abo 4 |
Urdu | ur |
1، 2، 3، اور 4 | 1، 2، 3، یا 4 |
Uzbek | uz |
1, 2, 3 va 4 | 1, 2, 3 yoki 4 |
Vietnamese | vi |
1, 2, 3 và 4 | 1, 2, 3 hoặc 4 |
Welsh | cy |
1, 2, 3 a 4 | 1, 2, 3 neu 4 |
Yoruba | yo |
1, 2, 3, 4 | 1 pẹ̀lú 2, 3, tabi 4 |
Yoruba (Benin) | yo_BJ |
1, 2, 3, 4 | 1 pɛ̀lú 2, 3, tabi 4 |
* The following English variants use an Oxford comma in addition to
en_GB
: en_AG
, en_AI
,
en_AT
, en_AU
, en_BB
,
en_BE
, en_BM
, en_BS
,
en_BW
, en_BZ
, en_CA
,
en_CC
, en_CH
, en_CK
,
en_CM
, en_CX
, en_CY
,
en_DE
, en_DG
, en_DK
,
en_DM
, en_ER
, en_FI
,
en_FJ
, en_FK
, en_FM
,
en_GD
, en_GG
, en_GH
,
en_GI
, en_GM
, en_GY
,
en_HK
, en_IE
, en_IL
,
en_IM
, en_IN
, en_IO
,
en_JE
, en_JM
, en_KE
,
en_KI
, en_KN
, en_KY
,
en_LC
, en_LR
, en_LS
,
en_MG
, en_MO
, en_MS
,
en_MT
, en_MU
, en_MV
,
en_MW
, en_MY
, en_NA
,
en_NF
, en_NG
, en_NL
,
en_NR
, en_NU
, en_NZ
,
en_PG
, en_PK
, en_PN
,
en_PW
, en_RW
, en_SB
,
en_SC
, en_SD
, en_SE
,
en_SG
, en_SH
, en_SI
,
en_SL
, en_SS
, en_SX
,
en_SZ
, en_TC
, en_TK
,
en_TO
, en_TT
, en_TV
,
en_TZ
, en_UG
, en_VC
,
en_VG
, en_VU
, en_WS
,
en_ZA
, en_ZM
, and en_ZW
.
Partially supported languages generally localize and()
but not or()
.
Language | Code | and example |
---|---|---|
Bodo | brx |
1, 2, 3, आरो 4 |
Chakma | ccp |
1, 2, 3 𑄃𑄳𑄃 4 |
Colognian | ksh |
1, 2, 3 un 4 |
Dogri | doi |
1, 2, 3, ते 4 |
Dzongkha | dz |
1 དང་ 2 དང་ 3 དང་ 4 |
Ewe | ee |
1, 2, 3, kple 4 |
Friulian | fur |
1, 2, 3 e 4 |
Igbo | ig |
1, 2, 3, na 4 |
Kashmiri | ks |
1، 2، 3، تٕہ 4 |
Luxembourgish | lb |
1, 2, 3 a(n) 4 |
Maithili | mai |
1, 2, 3, और 4 |
Maltese | mt |
1, 2, 3, u 4 |
Manipuri | mni |
1, 2, 3 অমসুং 4 |
Ngomba | jgo |
1, ŋ́gɛ 2, ŋ́gɛ 3, ḿbɛn ŋ́gɛ 4 |
Northern Sami | se |
1, 2, 3 ja 4 |
Ossetic | os |
1, 2, 3 ӕмӕ 4 |
Pashto | ps |
1، 2، 3، او 4 |
Sanskrit | sa |
1, 2, 3, तथा 4 |
Sundanese | su |
1, 2, 3, sareng 4 |
Swiss German | gsw |
1, 2, 3 und 4 |
Tatar | tt |
1, 2, 3 һәм 4 |
Walser | wae |
1, 2, 3 und 4 |
Western Balochi | bgn |
1، 2، 3، و 4 |
Western Frisian | fy |
1, 2, 3 en 4 |
Yakut | sah |
1, 2, 3 уонна 4 |
Yiddish | yi |
1, 2, 3 און 4 |
Zulu | zu |
1, 2, 3, ne-4 |
Hex sticker image by Flavia Rossell Hayes.
Please note that and is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.