Last active
November 26, 2017 10:40
-
-
Save scrogster/4d541af6ea68470819ecbdc385879bb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#function to substitute vowels with Maori macrons into text strings in R | |
#there's probably a fancier way to do this, but it works OK. | |
#just precede vowels requiring a macron with '@' and the function will substitute the appropriate vowel with macron. | |
#Handy for graph labelling etc. | |
maorify<-function(x){ | |
x<-gsub("@a","\u0101", x) #macron a | |
x<-gsub("@e","\u0113", x) #macron e | |
x<-gsub("@i","\u012B", x) #macron i | |
x<-gsub("@o","\u014D", x) #macron o | |
x<-gsub("@u","\u016B", x) #macron u | |
return(x) | |
} | |
#Example usage | |
hist(rpois(1000, 5), xlab=maorify("Number of T@u@i per hectare"), | |
main=maorify("Density of T@u@i at Whakat@ane")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment