Skip to content

R RPGM Functions

These functions are useful in every step of an RPGM app.

Functions

rpgm.addToEndScreen(filepath)

Adds a file to the list in the final end step. Path can be absolute or relative to your program directory.

rpgm.appVersion()

Returns the latest version found in the latest app's project changelog entry. If no version exists, returns an empty string.

rpgm.executeInPython(code)

R only. Execute the code string in Python.

rpgm.executeInR(code)

Python only. Execute the code string in R.

rpgm.isServer()

Returns TRUE if the app is executed on RPGM Server, FALSE otherwise.

rpgm.notification(type, message, duration = 5000)

Displays a notification in the bottom right corner of the screen. The notification lasts duration milliseconds and displays message. type can be:

  • "error" for a red message;
  • "info" for a blue message;
  • "success" for a green message.

rpgm.off(message, callback)

Remove a callback function from the event system called with rpgm.on() before.

rpgm.on(message, callback)

Set a callback function when RPGM emit an new event. Currently, there is 3 events:

  • didReceiveMessage: when receiving a message from another language like Javascript, Python or R;
  • didUserConnect: when the user connected to the app instance;
  • didUserInitialized: when the user is connected to the app instance and has finished loading Javascript files.

The callback argument is a function that will be called when the message is emitted.

rpgm.open(file)

  • In RPGM, opens a file with the default associated program.
  • In RPGM Server, depending on the file type, it will either open the file in a new browser tab or will download the file.

Please note that the file must be in the output folder or the app folder of the app.

rpgm.outputFile(filename)

Returns an absolute path to a named filename in the output directory.

rpgm.outputFileURL(filename)

Mainly used in RPGM Server, this function returns the full URL to a file named filename in the output directory.

rpgm.pgmFilePath(filename)

Returns an absolute path to a named filename in the program directory.

rpgm.playSound(sound)

Plays a sound. Sound can be either "success" or "error".

rpgm.setNextSequence(step)

Sets the next step of the sequence to the specified Step.

rpgm.sendEmail(to, subject, text = "", html = "", cc = "", bcc = "", attachments = list(), replyto = "")

RPGM Server only. Sends an email. to, subject are mandatory. Either text or html should be used (both is also possible).

  • to is a string to the recipient address;
  • subject email subject;
  • text plain text content of the email;
  • html HTML content of the email;
  • cc and bcc other addresses to send the email to;
  • attachments a list() of files to include in the email. Each file is a list with filename and a path properties. For example: list(filename="report.pdf", path="rpgm.outputFile("doc.pdf");
  • replyto an email address to respond to.

rpgm.sendToClipboard(value, headers=FALSE)

Send a value to the user clipboard. If sending an R dataframe, setting headers to TRUE will also append the data with the data frame's headers.

Note

For this to work on RPGM Server, you have to be on HTTPS.

rpgm.sendToJavascript(message, value)

Send a message packet to Javascript, with message as a string and a list of values in value.

rpgm.sendToPython(variableName, content)

Will create a variable variableName in Python with content content.

rpgm.step(file, stepid)

Creates a Step object, used in a lot of GUI functions.

rpgm.userEmail()

Returns a string with the email address of the user. On RPGM Server, it's the email associated to the user. On RPGM, it's the email of the connected user. If the user is not connected, it returns an empty string.

rpgm.userName()

Returns the name of the current user. On RPGM Server, it's the name of the user as defined in its account settings. On RPGM, it's the Windows/Linux/MacOS username.

rpgm.version()

Returns a string containing the version of RPGM or RPGM Server.