Dodge
Dodge

Reputation: 3309

How can I assign values to a greek letter while writing a script in RStudio?

I would like to use <- to assign values to Greek letters or other symbols, just as I can assign a value the letter 'A'. Does a method exist for incorporating symbols into an R script?

I am writing scripts in RStudio.

Upvotes: 1

Views: 171

Answers (1)

Gladwell
Gladwell

Reputation: 328

Possible but perhaps a bit more annoying than using alpha, beta, gamma, etc.

greek <- c("α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ", "λ", "μ", "ν", "ξ", "ο", "π", "ρ", "σ", "τ", "υ", "φ", "χ", "ψ", "ω")

for (g in greek) assign(g, toupper(g))

for (g in greek) print(paste(g, get(g), sep=":"))
[1] "α:Α"
[1] "β:Β"
[1] "γ:Γ"
[1] "δ:Δ"
[1] "ε:Ε"
[1] "ζ:Ζ"
[1] "η:Η"
[1] "θ:Θ"
[1] "ι:Ι"
[1] "κ:Κ"
[1] "λ:Λ"
[1] "μ:Μ"
[1] "ν:Ν"
[1] "ξ:Ξ"
[1] "ο:Ο"
[1] "π:Π"
[1] "ρ:Ρ"
[1] "σ:Σ"
[1] "τ:Τ"
[1] "υ:Υ"
[1] "φ:Φ"
[1] "χ:Χ"
[1] "ψ:Ψ"
[1] "ω:Ω"

GREEK <- toupper(greek)

Upvotes: 1

Related Questions