Translate R Code to English

The R Code Translator Add-In For MacOS

The addin allows you to select any R expression and have it vocalised on macOS. The expression can be a dataframe, character vector or list.

Each translation is saved into an object, which can be viewed in the environment pane of RStudio. It can also be modified by using the Work With User Defined Code Type Language Translation form or by selecting the item in the glossary tab.

What is r code translator?

R is a high-level, interpreted programming language. It supports procedural, object-oriented, and functional programming styles. It is often used for statistical computing and graphical display of data. The language is highly extensible. It has an extensive library of functions and support for a number of programming environments including RStudio.

Translating a bare or quoted R expression to English is the responsibility of the function translate() and translate_string(). Both functions use non-standard evaluation and break the R expression into tokens. They match these with an opinionated list of English translations and reassemble the result into an English sentence.

R’s messages are divided into domains: the en_US domain for error and warning messages; the pkg and RGui domains for messages from the C-level code of each package and the R base package; and the r2eng domain for the menus and other GUI-related messages. Each domain may have one or more translation catalogues. Chunks of R code are evaluated from top to bottom and left to right. A chunk that includes an action of assignation or printing must be separated from a printing chunk by an empty line.

How to use r code translator?

R is a dynamic programming language, meaning that it interprets the human-readable code you type as machine-readable 1s and 0s. In contrast, some languages have to compile your code before you can run it.

r2eng takes an R expression and translates it into English by recognising the tokens that make up an R expression (thanks to lintr). It then recombines the recognised tokens into an English sentence. It also allows you to set the argument speak = TRUE to cause a system call to vocalise the translated English text on macOS.

This functionality is similar to how RStudio handles functions by translating their human-readable code into machine-readable functions. However, this is a little more complete, since it will translate the R code that is in a function as well. This means that you can have a translation for every line of an R script. This can be helpful if you need to produce reports that are formatted using LaTeX, for example.

How to install r code translator?

R supports the translation of its messages, including error and warning messages and menu labels. This document is intended for translation teams but starts with a user’s view of the process extracted from the R Installation and Administration Manual. Messages are divided into domains: R for C-level error and warning messages from the R interpreter, pkg for messages in each package (including the base package), R-gui for the menus etc in the GUI front-end of the Windows program that comes with R, and R-base for the interpreted code in the R core.

r2eng hijacks this process and, using a new function that is partly based on lintr, recognises the ‘tokens’ of an R expression and translates each one into an English word. The resulting text is then handed to your machine for vocalisation (on a Mac this uses the built-in VoiceOver text-to-speech converter). You can bind this addin to a keyboard shortcut in RStudio: go to ‘Addins’, ‘Show Addins’ and find ‘r2eng’.

What is the cost of r code translator?

R is free to download and use, and there are no monthly or annual fees. However, if you want to translate text using the Google Translation API, you’ll need to register for an API account and receive some sort of authentication—a token or a pair of secret parts of an authenticator—to gain access. In some cases, you may also be required to provide credit card information when registering for an API account. This is typically done for higher-volume APIs.

Leave a Reply

Your email address will not be published. Required fields are marked *