Accessing RStudio Server through node-RED

33 Views Asked by At

I am working with node-red and I need to run an R script that will take as input an array from the node-red flow. I deployed the RStudio Server through Docker and it works fine when I enter through http://localhost:8787/.

To connect it to node-red I used: https://flows.nodered.org/flow/96b312540d537d708eb4d35b94684c42 with the needed credentials regarding username and password. In node-red when i run the flow I get no errors and no result either. My node-red is running on http://127.0.0.1:1880/ . Any ideas what might be causing the problem?

My flow is:

[
    {
        "id": "1b800ebff244587f",
        "type": "inject",
        "z": "ae326d3360170ce4",
        "name": "Demodata input",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"data\":[0.48,-5.21,-0.21,7.81,10.43,13.81,16.24,15.89,12.56,8.04,2.79,-0.11,-2.39,6.01,15.31,7.8,0.21,12.79,6.88]}",
        "payloadType": "json",
        "x": 160,
        "y": 340,
        "wires": [
            [
                "01c44451b142384b"
            ]
        ]
    },
    {
        "id": "01c44451b142384b",
        "type": "R Script",
        "z": "ae326d3360170ce4",
        "RServer": "1ade99a1681f1663",
        "script": "msg$payload$mean = mean(msg$payload$data)\nmsg$payload$median = median(msg$payload$data)",
        "name": "Calculate mean and median using R",
        "x": 450,
        "y": 220,
        "wires": [
            [
                "2ce646982712e758"
            ]
        ]
    },
    {
        "id": "2ce646982712e758",
        "type": "debug",
        "z": "ae326d3360170ce4",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 690,
        "y": 280,
        "wires": []
    },
    {
        "id": "1ade99a1681f1663",
        "type": "R Server",
        "host": "localhost",
        "port": "8787",
        "name": "RStudio Server"
    }
]
0

There are 0 best solutions below