I'm looking for a compiler that can convert R code into JavaScript. Where can I find one

Recently, I have transitioned to coding solely in R after delving into the functionalities of dplyr and ggplot2. Now, I am on the lookout for an R-to-JavaScript compiler that would enable me to create extensions for Google Chrome. Do you know where I can find one?

If necessary, I am prepared to develop the compiler myself, but it must be done using R.

Answer №1

One of the reasons why R functions so well as a specialized mathematics-focused language is due to its highly optimized R interpreter/JIT and runtime.

Similarly to MATLAB or Mathematica, or even utilizing numpy in conjunction with Python,

If one were to transpile R code into JS, the performance would likely fall short in comparison, especially when trying to execute complex computations typically handled by an R program (particularly if the R code involves intricate calculations).

There doesn't appear to be any existing project focused on compiling R to JS - suggesting it may not be a demanded feature.

The JavaScript-only ecosystem in Chrome extensions seems ill-suited for executing R code within.

If using Firefox or IE, it becomes possible to access DLLs from within extensions - leveraging COM on IE and the FF native bridge API. Unfortunately, Chrome lacks direct support for such capabilities.

An effective solution is developing an NPAPI plugin - introducing a bit of native code in the form of a DLL that can be interacted with through JS using an OBJECT tag. I have utilized this method to create an extension replacing Flash video controls with a windowless VLC player across Chrome, FF, and IE. This approach proves to be the most efficient. Write your R code, convert it into a DLL, expose the interface via an NPAPI plugin. Then, inject an OBJECT tag into the HTML within your extension, which will instantiate your native code instance - allowing you to directly invoke methods as if interacting with a JS object.

An alternative solution could involve translating R to MATLAB, converting the MATLAB code into C++ (which is feasible), and subsequently running the C++ as native client code in the browser.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The occurrence of Multiple Button events leads to an error message stating: "Uncaught TypeError: Cannot read property 'remove' of undefined"

I am struggling to add an EventListener to each Delete Button (1,2,3) as I keep encountering an error that says "add" is undefined. Do you have any suggestions on how to fix this issue? My goal is to display a confirmation window when the DELETE button is ...

Combining Arrays in AngularJS for ng-repeat Iteration

I store my posts in a .json file, while the likes for each post are saved in a separate php file connected to my database. let likesList = []; $http({ method: 'GET', url: 'data/get_likes.php' }).then(function(response) { ...

Retrieve the most recent version based on the provided ID and date within the array

I am working with an array of JavaScript objects that have specific properties: _id, isVersionFrom, createdAt. The _id and isVersionFrom properties store MongoDB _ids (with isVersionFrom being false for the original object), while createdAt stores a timest ...

Struggling to hide empty columns in an HTML table with jQuery - it's just not cooperating!

<html> <head> <script src="jquery-1.4.4.js"></script> <script> $('table').each(function(a, tbl) { var currentTableRows = $(tbl).attr('rows').length - 1; $(tbl).fin ...

"Utilize Regular Expressions to conceal part of a text string with a

Looking for a way to conceal part of a string using JavaScript? For example, wanting to mask the second and third segments of a credit card number like this using regex: 4567 6365 7987 3783 → 4567 **** **** 3783 3457 732837 82372 → 3457 ****** 82372 ...

Steps to creating a nested function

I'm still learning the ropes of Javascript, and I've been working on creating a personal library to streamline my coding process. Here's the code snippet I've come up with. function myLibrary() { let _this = this; this.addString = ...

How to manipulate a jade element with JavaScript

How can I capture the value of an input tag in real time and store it in a JSON object? In my Jade file, this is what it looks like: extends layout block content h1 todos #task <input type="text" id="task" name="task"/> #todos for todo ...

Objective: Remove all soft items from array stored in MongoDb using Mongoose

I have a unique Array property in my document that is filled with lovely fluffy objects. Now, I am looking to remove all objects within a specific range -> qdate:20210225. The property in the database is named weeks and appears as follows: [ { ...

Retrieving a result from a function call is a fundamental aspect of programming

I have a scenario where I am initiating a call from a controller within AngularJS. This call passes some data to a service in order to receive a response that needs to be conditionally checked. Controller patents.forEach(function(item){ // The "patents" ...

Creating a single page application in Angular2+ using JSON data

I am looking to create an Angular JS application using the provided JSON structure: { name: 'App Name', pages: [ { name: 'Home', url: '/', layout: { type:'HTMLElement' tag:'div ...

Testing ng-content in Angular 2

Is there a way to test the functionality of ng-content without the need to create a host element? For instance, let's say we have an alert component - @Component({ selector: 'app-alert', template: ` <div> <ng-conten ...

Oops! There was an error: Unable to find a solution for all the parameters needed by CountdownComponent: (?)

I'm currently working on creating a simple countdown component for my app but I keep encountering an error when I try to run it using ng serve. I would really appreciate some assistance as I am stuck. app.module.ts import { BrowserModule } from &apo ...

Solution: The issue where the children's onChange event was not updating the parent in Ant Design was discovered to be due to the Select and Table components nested inside a Tab not changing according to the pageSize

I'm facing an issue with updating a parent element when the children's onChange event is triggered. Specifically, I have an Ant Design Select and Table inside a Tab that are not reflecting changes in the pageSize value. Although setPageSize func ...

When attempting to call a script function in PHP and expecting a return value, an error was encountered: "Uncaught SyntaxError

My functions are working fine: <script> function createCookie(name,value,sec) { if (sec) { console.log('createCookie: '+name+', '+value+', '+sec); var date = new Date(); date.setTime(date.getTime()+(sec*1000 ...

Establishing limitations for sap.m.DatePicker

Is there a way to enforce minimum and maximum date constraints on my DatePicker? I want to ensure that if a user selects a date outside the allowed range, it either doesn't trigger a change event or automatically reverts to a valid date. I am using 2 ...

Assign the value in the text box to the PHP session variable

Currently, I am developing a PHP "interactive text game" as a part of my assignment project. My task involves creating a user interface where users input information (such as character names) into text boxes that appear sequentially as they complete the p ...

Chrome full screen mode can be toggled on websites after ajax data has loaded

I am currently experiencing a frustrating issue with Chrome on my webpage. The pagination feature loads content via an ajax call at: Whenever I click on the 2nd, 3rd, or subsequent tab in the pagination, the load process occurs but then suddenly jumps int ...

Rows with Matching String Values in DataFrame

My data frame in R contains several rows with slightly different wording for the same disease (e.g., using "+" or ">" interchangeably). Is there a way to efficiently identify and merge these rows? Here are a few examples: Row 59: 872 - SEPTICEMIA OR ...

The onChange method in React is failing to execute within the component

I am having trouble overriding the onChange method in a component. It seems like the method is not triggering on any DOM events such as onChange, onClick, or onDblClick. Below are the snippets of code where the component is rendered and the component itsel ...

Troubleshooting the Issue of Angular Model Not Refreshing in Angular.js

Running into an issue with my directive where the model isn't updating as expected. Here's a snippet of my HTML code: <div class="text-area-container"> <textarea ng-model="chatText" ng-keyup="updateCount(chatText)">< ...